Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix][broker] Broker is failing to create non-durable sub if topic is fenced #23579

Merged
merged 1 commit into from
Nov 11, 2024

Conversation

rdhabalia
Copy link
Contributor

@rdhabalia rdhabalia commented Nov 9, 2024

It should fix: #23564

Motivation

Currently if topic gets fenced for some reason (eg: Metadata-BadVersion) then broker is not allowing non-durable sub to be created and keep failing with below errors because broker is not closing and recreating topic to recover this error in case of non-durable sub where as broker does it during dutable-sub or producer creation.

Caused by: org.apache.bookkeeper.mledger.ManagedLedgerException$ManagedLedgerFencedException: java.lang.Exception: Attempted to use a fenced managed ledger
Caused by: java.lang.Exception: Attempted to use a fenced managed ledger
        at org.apache.bookkeeper.mledger.ManagedLedgerException$ManagedLedgerFencedException.<init>(ManagedLedgerException.java:80) ~[org.apache.pulsar-managed-ledger-3.3.4.jar:3.3.4]
        at org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl.checkFenced(ManagedLedgerImpl.java:3922) ~[org.apache.pulsar-managed-ledger-3.3.4.jar:3.3.4]
        at org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl.newNonDurableCursor(ManagedLedgerImpl.java:1126) ~[org.apache.pulsar-managed-ledger-3.3.4.jar:3.3.4]
        at org.apache.pulsar.broker.service.persistent.PersistentTopic.getNonDurableSubscription(PersistentTopic.java:1217) ~[org.apache.pulsar-pulsar-broker-3.3.4.jar:3.3.4]
        at org.apache.pulsar.broker.service.persistent.PersistentTopic.lambda$internalSubscribe$25(PersistentTopic.java:1032) ~[org.apache.pulsar-pulsar-broker-3.3.4.jar:3.3.4]
        ... 20 more
2024-11-08T00:00:00,977+0000 [BookKeeperClientWorker-OrderedExecutor-0-0] WARN  org.apache.pulsar.broker.service.ServerCnx - [/1.1.1.1:36284][persistent://pulsar/broker-0:8080/healthcheck][healthCheck-10bdfffe-6fe4-44a5-b648-db8112c0b982] Failed to create consumer: consumerId=1345, java.lang.Exception: Attempted to use a fenced managed ledger
java.util.concurrent.CompletionException: org.apache.bookkeeper.mledger.ManagedLedgerException$ManagedLedgerFencedException: java.lang.Exception: Attempted to use a fenced managed ledger
        at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:332) ~[?:?]
        at java.base/java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:1177) ~[?:?]
        at java.base/java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:2309) ~[?:?]
        at org.apache.pulsar.broker.service.persistent.PersistentTopic.lambda$internalSubscribe$25(PersistentTopic.java:1035) ~[org.apache.pulsar-pulsar-broker-3.3.4.jar:3.3.4]
        at java.base/java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:1187) ~[?:?]
        at java.base/java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:2309) ~[?:?]
        at org.apache.pulsar.broker.service.persistent.PersistentTopic.internalSubscribe(PersistentTopic.java:956) ~[org.apache.pulsar-pulsar-broker-3.3.4.jar:3.3.4]
        at org.apache.pulsar.broker.service.persistent.PersistentTopic.subscribe(PersistentTopic.java:930) ~[org.apache.pulsar-pulsar-broker-3.3.4.jar:3.3.4]
        at org.apache.pulsar.broker.service.ServerCnx.lambda$handleSubscribe$19(ServerCnx.java:1351) ~[org.apache.pulsar-pulsar-broker-3.3.4.jar:3.3.4]
        at java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1150) ~[?:?]
        at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510) ~[?:?]
        at java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2147) ~[?:?]
        at org.apache.pulsar.broker.service.schema.BookkeeperSchemaStorage$Functions.lambda$getLedgerEntry$0(BookkeeperSchemaStorage.java:684) ~[org.apache.pulsar-pulsar-broker-3.3.4.jar:3.3.4]
        at org.apache.bookkeeper.client.LedgerHandle$6.onSuccess(LedgerHandle.java:1050) [org.apache.bookkeeper-bookkeeper-server-4.17.1.jar:4.17.1]
        at org.apache.bookkeeper.client.LedgerHandle$6.onSuccess(LedgerHandle.java:1047) [org.apache.bookkeeper-bookkeeper-server-4.17.1.jar:4.17.1]
        at org.apache.bookkeeper.common.concurrent.FutureEventListener.accept(FutureEventListener.java:42) [org.apache.bookkeeper-bookkeeper-common-4.17.1.jar:4.17.1]
        at org.apache.bookkeeper.common.concurrent.FutureEventListener.accept(FutureEventListener.java:26) [org.apache.bookkeeper-bookkeeper-common-4.17.1.jar:4.17.1]
        at java.base/java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:863) [?:?]
        at java.base/java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:841) [?:?]
        at java.base/java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482) [?:?]
        at org.apache.bookkeeper.common.util.SingleThreadExecutor.safeRunTask(SingleThreadExecutor.java:137) [org.apache.bookkeeper-bookkeeper-common-4.17.1.jar:4.17.1]
        at org.apache.bookkeeper.common.util.SingleThreadExecutor.run(SingleThreadExecutor.java:107) [org.apache.bookkeeper-bookkeeper-common-4.17.1.jar:4.17.1]
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [io.netty-netty-common-4.1.111.Final.jar:4.1.111.Final]
        at java.base/java.lang.Thread.run(Thread.java:833) [?:?]

Modifications

Fix broker behavior to recover fenced topic and allow non-durable sub to connect on topic.

Verifying this change

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

This change is a trivial rework / code cleanup without any test coverage.

(or)

This change is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Added integration tests for end-to-end deployment with large payloads (10MB)
  • Extended integration test for recovery after broker failure

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository:

@rdhabalia rdhabalia added area/broker doc-not-needed Your PR changes do not impact docs ready-to-test labels Nov 9, 2024
@rdhabalia rdhabalia added this to the 4.1.0 milestone Nov 9, 2024
@rdhabalia rdhabalia self-assigned this Nov 9, 2024
Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

Copy link
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rdhabalia rdhabalia merged commit 7822dca into apache:master Nov 11, 2024
55 of 59 checks passed
@rdhabalia rdhabalia deleted the read_fe branch November 11, 2024 20:26
lhotari pushed a commit that referenced this pull request Nov 13, 2024
lhotari pushed a commit that referenced this pull request Nov 13, 2024
lhotari pushed a commit that referenced this pull request Nov 13, 2024
nikhil-ctds pushed a commit to datastax/pulsar that referenced this pull request Nov 20, 2024
… fenced (apache#23579)

(cherry picked from commit 7822dca)
(cherry picked from commit bdeab6c)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Nov 21, 2024
… fenced (apache#23579)

(cherry picked from commit 7822dca)
(cherry picked from commit bdeab6c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants