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] Close dispatchers stuck due to mismatch between dispatcher.consumerList and dispatcher.consumerSet by poorbarcode · Pull Request #22270 · apache/pulsar Conversation
Contributor
MotivationThe logs were printed on our cluster(
[1]: dispatcher.disconnectAllConsumers public synchronized CompletableFuture<Void> disconnectAllConsumers() { consumerList.forEach(consumer -> consumer.disconnect(isResetCursor, assignedBrokerLookupData)); } [2]: dispatcher.removeConsumer public synchronized void removeConsumer(Consumer consumer) throws BrokerServiceException { // decrement unack-message count for removed consumer addUnAckedMessages(-consumer.getUnackedMessages()); if (consumerSet.removeAll(consumer) == 1) { consumerList.remove(consumer); log.info("Removed consumer {} with pending {} acks", consumer, consumer.getPendingAcks().size()); if (consumerList.isEmpty()) { if (closeFuture != null) { closeFuture.complete(null); // Once the log "Trying to remove a non-connected consumer" was printed, it means the closeFuture will never be completed. } } } else { log.info("[{}] Trying to remove a non-connected consumer: {}", name, consumer); } } ModificationsI haven't found the logic of repeating consumer in Documentation
Matching PR in forked repositoryPR in forked repository: x
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions…consumerList and dispatcher.consumerSet
Merged
1 of 4 tasks
hanmz
approved these changes
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. LGTM
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
lhotari
reviewed
Uh oh!
There was an error while loading. Please reload this page.
lhotari
approved these changes
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. LGTM
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
2 of 5 tasks
|
There was an error while loading. Please reload this page.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@ ## master #22270 +/- ## ============================================ + Coverage 73.57% 73.68% +0.10% - Complexity 32624 32802 +178 ============================================ Files 1877 1887 +10 Lines 139502 139488 -14 Branches 15299 15293 -6 ============================================ + Hits 102638 102778 +140 + Misses 28908 28750 -158 - Partials 7956 7960 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It looks like we don't need this PR if we follow this comment to fix the issue. I have tested on my laptop.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Changed the implementation: Just add a defensive code to avoid the topic not being unloaded anymore: remove the consumers which are not mismatched between |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
/pulsarbot rerun-failure-checks |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…cher.consumerList and dispatcher.consumerSet (apache#22270) (cherry picked from commit cba1600) (cherry picked from commit 94edfe4)
…cher.consumerList and dispatcher.consumerSet (apache#22270) (cherry picked from commit cba1600) (cherry picked from commit 94edfe4)
…cher.consumerList and dispatcher.consumerSet (apache#22270) (cherry picked from commit cba1600) (cherry picked from commit 94edfe4)
…cher.consumerList and dispatcher.consumerSet (apache#22270) (cherry picked from commit cba1600) (cherry picked from commit 94edfe4)
…cher.consumerList and dispatcher.consumerSet (apache#22270) (cherry picked from commit cba1600) (cherry picked from commit 94edfe4)
…cher.consumerList and dispatcher.consumerSet (apache#22270) (cherry picked from commit cba1600)
…cher.consumerList and dispatcher.consumerSet (apache#22270)
…lly removed
### Motivation
`PersistentDispatcherMultipleConsumers#removeConsumer` debited the subscription's
un-acknowledged message count by the departing consumer's own count before it
established whether that consumer was still registered:
addUnAckedMessages(-consumer.getUnackedMessages());
if (consumerSet.removeAll(consumer) == 1) {
The `else` branch below is the defensive path added by apache#22270 for a consumer that is
still in `consumerList` but no longer in `consumerSet`, so that the topic can still be
unloaded. Reaching it means the consumer was already removed once, and the first
removal already debited its un-acknowledged messages. The unguarded debit therefore
subtracts them a second time and drives `totalUnackedMessages` negative.
That counter is what `maxUnackedMessagesOnSubscription` throttles on, and nothing
resets it while the dispatcher lives — `clearComponentsAfterRemovedAllConsumers()`
resets the available-permits aggregate but deliberately leaves it alone. A negative
value therefore silently disables the throttle for the lifetime of the dispatcher.
### Modifications
Move the debit inside the `consumerSet.removeAll(consumer) == 1` guard, so that only
the removal which actually unregisters the consumer accounts for it. The defensive
branch needs no debit of its own, for the same reason: the first removal already made
it.
### Verifying this change
Adds `SharedSubscriptionAvailablePermitsInvariantTest#testRemovingSameConsumerTwiceDebitsUnackedMessagesOnce`,
which leaves a consumer holding ten un-acknowledged deliveries, removes it twice and
requires the subscription counter to end at zero. Without this change it ends at -10.
This is broker-internal accounting: no public API, configuration or wire-protocol
change.
Signed-off-by: Florentin Dubois <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.