GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — [fix][broker] Stop read retries for drained terminated topics by poorbarcode · Pull Request #27661 · apache/pulsar Conversation
Contributor
BackgroundAfter terminating an empty non-partitioned topic, an Exclusive consumer with a MotivationThe dispatcher handles terminal EOF by notifying consumers when the subscription backlog is empty, but then schedules another read through the generic failure-retry path. Once the waiting-read reservation is correctly released, each retry can reach EOF again, causing unnecessary broker work and repeated listener notifications. This addresses the review follow-up to #27381. Modifications
The regressions reproduced duplicate notifications and unwanted retries before the fix. The final scoped run passed all 12 cases in Does this pull request potentially affect one of the following parts:
Public API:
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsStop automatic EOF read retries after confirming that a non-migrated terminated topic has no precise backlog. Preserve existing notification behavior and retries for migration or remaining backlog, and cover all subscription types and resubscription. Assisted-by: Codex
codelipenghui
requested changes
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stopping the EOF retry fixes the repeated callback, but it also removes the only notification path for a Failover standby that joins after the subscription has drained and the active consumer stays connected. The 12 focused tests passed; the Failover test closes the first consumer before adding the second, so it does not cover this regression.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Notify a late-joining Failover standby without restarting EOF polling On an empty terminated topic, leave the active Failover consumer connected after its EOF callback. Then attach a lower-priority consumer to the same subscription so it remains on standby. The standby can wait indefinitely for reachedEndOfTopic(), with hasReachedEndOfTopic() still false, even though the topic is terminated and there are no messages to consume. The EOF handler notifies only consumers already connected, then returns here without scheduling another read. When the standby joins, pickAndScheduleActiveConsumer() returns false because the active consumer is unchanged; internalAddConsumer() sends only an active-consumer-change notification. The standby's initial FLOW is ignored by internalConsumerFlow() because it is not active (lines 298–301). Previously the delayed read would hit EOF again and notify the expanded consumer list. Keep the retry stopped, but send EOF specifically to a newly attached standby when the topic is terminated, non-migrated and precisely drained. Add a two-consumer Failover test that keeps the active consumer connected, waits for its first callback, attaches the standby, and verifies one callback for each without another notification to the active consumer.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for catching this. Fixed in d8e770a. A late-joining Failover standby now receives EOF when the topic is terminated, has not migrated, and the subscription backlog is empty. EOF read retries stay stopped. The two-consumer regression keeps the active consumer connected and verifies exactly one callback for each consumer.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsNotify newly joined standby consumers after a terminated topic is drained without restarting EOF read retries. Deduplicate dispatcher notifications per connected consumer and clear the notification state on removal or cursor reset. Add regression coverage for late joins, EOF callback ordering, reconnects, cursor resets, migration, backlog, and live topics. Assisted-by: Codex
codelipenghui
requested changes
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The follow-up fixes the missing EOF callback for a standby that joins an already-drained Failover subscription, without restarting read retries. All 21 focused cases passed. One gap remains: a standby that joins while the topic is being terminated can receive the callback twice because the termination broadcast bypasses the new deduplication.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Comment on lines
+120
to
+121
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deduplicate standby EOF against the topic-termination broadcast Terminate an empty topic with an active Failover consumer, and attach a lower-priority standby after the ledger marks itself terminated but before the asynchronous termination completes. The new standby receives reachedEndOfTopic() once on join and again when termination completes. A listener that reacts to EOF therefore runs twice for the same end of the same subscription. ManagedLedgerImpl.java:1799–1809 marks the ledger terminated before its completion callback. The new join hook sees that state and calls notifyEndOfTopicOnce(). On completion, PersistentTopic.java:4839–4841 invokes PersistentSubscription.java:1741–1746, which broadcasts through the static helper rather than the dispatcher override. The final-ack broadcast also uses the static helper. The client invokes the listener on every EOF command. Route the single-active subscription's drained, non-migrated EOF broadcasts through the same per-consumer guard as standby joins and read EOF. Preserve the migration path and keep polling disabled. Add a regression that joins a standby before the termination broadcast and checks that it receives exactly one callback.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
lhotari
reviewed
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for following up on #27381 and for the thorough set of dispatcher tests. Stopping the EOF retry loop on a drained terminated topic makes sense. Two things should be addressed before merging:
The remaining comments are smaller: the standby notification is sent before the subscribe response, a paused Shared or Key_Shared joiner, and a duplicated backlog check.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [BUG] Stopping the retry can leave an entry undelivered if its add was in flight when termination started
If a fresh read is issued in that window, After that, nothing starts another read:
Scenario: a caught-up consumer, and a publish in flight while the topic is terminated. The consumer gets EOF (that early EOF already happens today), and the final message is not dispatched until the consumer reconnects or the topic is unloaded ( Possible fixes:
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [INTENT MISMATCH] The notify-once set is bypassed by the ack and terminate EOF paths, so drain-then-ack still notifies twice Only Scenario: an Exclusive or Failover listener consumer reads a terminated topic with N messages.
This is much better than the repeated callbacks before the change. Still, it does not match the "only one end-of-topic notification" goal in the updated Routing the subscription-level notifications through a dispatcher instance method that respects the set would close this gap. A test that publishes a message, terminates, then consumes and acks it would cover it.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [BUG] The standby EOF is sent inside addConsumer, before the subscribe success response
If that listener calls Sending a command before SUCCESS is not new (
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [QUALITY] Shared and Key_Shared get no matching late-joiner handling or dedup Failover now gets a standby hook and a notify-once set, but the multiple-consumers dispatcher still broadcasts through the base
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [QUALITY] The precise backlog is sampled twice per EOF, and the stop condition is duplicated in both dispatchers Nit: the override evaluates
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
codelipenghui
requested changes
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The head is unchanged. The original missing EOF callback for a late Failover standby is fixed in the steady-state case; the duplicate callback during termination is still open, and the new review shows the final-ack path has the same gap. The new discussion also identifies two distinct regressions: a committed final entry can remain undispatched, and a standby listener can run before SUBSCRIBE succeeds. Recommendation remains request changes.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Comment on lines
+614
to
+615
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not stop reads at EOF while an accepted publish can still become visible A caught-up consumer issues a fresh read during topic termination, after the ledger sets its terminated flag but before an already accepted add advances the last confirmed position. The last successfully published entry can remain undispatched to a connected consumer until another event restarts reads. The entry is still stored, but a consumer that trusts the early EOF can miss it entirely. ManagedLedgerImpl.java:1789–1838 sets the flag before close completes. ManagedCursorImpl.java:1271–1283 then removes the waiting read and emits EOF. Both this guard and PersistentDispatcherMultipleConsumers.java:1201–1202 stop retrying if the cursor is empty at that instant. Add completion wakes registered waiters only, and the subscription's termination callback does not restart reads when backlog remains. The managed-ledger test confirms that an accepted in-flight add can become the terminal entry; the dispatcher consequence was traced in source. Distinguish termination in progress from a finalized end position. Keep the read armed or retryable until that position is stable, then suppress polling once drained. Add a broker regression that gates an accepted add, issues a fresh read during termination, and asserts delivery without a reconnect or extra FLOW.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Comment on lines
+120
to
+121
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Queue standby EOF after the subscribe success response A Java listener calls closeAsync() from the EOF callback on its first subscription as a standby to an already-drained Failover topic. The initial subscribe future can remain pending even though the consumer has closed, leaving a synchronous subscribe() call waiting. The join hook sends EOF before ServerCnx.java:2456–2461 writes SUCCESS. The Java client has already registered the consumer and invokes its EOF listener directly. The not-connected close branch sets Closed without completing the subscribe future; the later SUCCESS handler takes the closed-consumer branch and returns before completing it (ConsumerImpl.java:1089–1121, close branch). Run the standby EOF check from a path explicitly ordered after SUCCESS; simply submitting it to another executor does not guarantee that order. Recheck membership and drain state there. Cover a listener that closes on EOF and assert that subscribing settles.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the same EOF guard for subscription broadcasts and dispatcher notifications Either a standby joins during termination before the subscription broadcast, or the final ack empties a terminated subscription after an EOF read has already queued a retry. The same connected consumer can receive two EOF callbacks for one drain. Stopping the periodic retry loop does not prevent this last duplicate. The per-consumer set only observes dispatcher notifications. The ack path and termination broadcast send directly through the static helper. In the final-ack case, the helper sends EOF without recording it, and the already scheduled retry sends it again when the cursor is empty. This is the same bypass as the prior standby-broadcast finding. Give normal, drained EOF notifications one path through the per-consumer guard, including final ack and termination; keep migration separate. Decide whether to notify and stop from one drain check where possible. Test both a join racing with termination and a real final ack followed by the already scheduled read.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReviewersRequested changes must be addressed to merge this pull request. Uh oh!
There was an error while loading. Please reload this page. AssigneesProjectsDevelopmentSuccessfully merging this pull request may close these issues. Uh oh!
There was an error while loading. Please reload this page. Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |