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] Debit un-acked messages only when the consumer is actually removed by FlorentinDUBOIS · Pull Request #26422 · apache/pulsar Conversation
Contributor
Relates to #26416. Carved out of #26417 following the review discussion there: the available-permits half of that PR is superseded by #26289, while this double-debit of the un-acknowledged message counter is an independent defect that neither master nor #26289 addresses, so it gets its own PR, review, and backport decision. Motivation
addUnAckedMessages(-consumer.getUnackedMessages()); if (consumerSet.removeAll(consumer) == 1) { The That counter is what
Modifications
Verifying this changeThis change added tests and can be verified as follows:
Both tests were run red-first against the unmodified production code, then green with the fix applied.
Does this pull request potentially affect one of the following parts:If the box was checked, please highlight the changes
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions…lly removed
### Motivation
`PersistentDispatcherMultipleConsumers#removeConsumer` debits the subscription's
un-acknowledged message count by the departing consumer's own count before it
establishes whether that consumer is 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,
and since `addUnAckedMessages` also feeds the broker-wide counter, the drift is not
confined to one subscription.
`PersistentDispatcherMultipleConsumersClassic#removeConsumer` carries the identical
unguarded debit.
### Modifications
Move the debit inside the `consumerSet.removeAll(consumer) == 1` guard in both the
current and the classic dispatcher, 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 — a comment in that
branch now records the invariant.
### Verifying this change
Adds `SharedSubscriptionUnackedMessagesAccountingTest`, which leaves a consumer
holding ten un-acknowledged deliveries, removes it twice and requires the
subscription counter to end at zero — once against the current dispatcher and once
against the classic one behind the dynamic
`subscriptionSharedUseClassicPersistentImplementation` flag. Without this change
both end at -10.
This is broker-internal accounting: no public API, configuration or wire-protocol
change.
Signed-off-by: Florentin Dubois <[email protected]>
1 of 10 tasks
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 splitting this out of #26417 — the carve-out was the right call, and the write-up made the review easy: the motivation, the invariant and the red-on-master evidence are all stated precisely. Welcome, and nice first patch. I verified the core claim independently against the code at
One candidate defect I chased down and ruled out: that The production change looks right to me. What I would still like addressed is on the test side, plus one accuracy point about the new comment — details inline. One caveat on my side, so you know exactly how far my check goes: I did not run the new tests locally. The red-on-master claim above is derived from reading the code rather than from an observed failing run, and the PR's own CI is green on
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsUh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. …rage Isolate dispatcher variants on dedicated brokers and verify both subscription and broker unacked totals after each removal. Clarify removal comments and use public dispatcher accessors with AssertJ assertions. Assisted-by: OpenAI Codex
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. The review feedback is addressed. Both dispatcher variants now use dedicated brokers and verify subscription and broker-wide unacked-message accounting after each removal. The removal comments and test assertions have also been updated. Validation: both dispatcher tests and quickCheck passed. Both variants fail with the original unconditional debit, and both detect the broker-wide double debit when only the subscription counter is reset.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Uh oh!
There was an error while loading. Please reload this page.
lhotari
added a commit
that referenced
this pull request
…lly removed (#26422) Signed-off-by: Florentin Dubois <[email protected]> Co-authored-by: Lari Hotari <[email protected]> (cherry picked from commit 5c078d8)
lhotari
added a commit
that referenced
this pull request
…lly removed (#26422) Signed-off-by: Florentin Dubois <[email protected]> Co-authored-by: Lari Hotari <[email protected]> (cherry picked from commit 5c078d8)
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
3 tasks done
FlorentinDUBOIS
added a commit
to CleverCloud/magnetar
that referenced
this pull request
The existing churn suite asserts that dispatch CONTINUES across a mid-drain consumer close. That is green on a broker whose permit ledger is leaking: `readMoreEntries` has fallen back to `max(totalAvailablePermits, firstAvailableConsumerPermits)` since 2021, so a negative aggregate is masked entirely. "Messages kept flowing" therefore proves nothing about issue #414's root cause. This suite asserts on the numbers the broker reports about itself instead: the dispatcher's `totalAvailablePermits` never negative, every per-consumer `availablePermits` inside `[0, receiver_queue_size]`, no negative `unackedMessages`, and a backlog that still reaches zero. The aggregate is exposed by no admin endpoint — measured absent from `…/stats`, `/admin/v2/broker-stats/topics`, `…/internalStats` and `/metrics` on 4.2.4 — so the suite raises the `PersistentDispatcherMultipleConsumers` debug logger inside the container and parses the counter out of the broker log. Parsing zero observations fails as an infrastructure fault rather than passing. It also fixes a real trap for 5.x: `WaitFor::message_on_stdout("Created namespace public/default")` times out there because 5.x logs it to stderr. It polls the namespace list instead, like `e2e_scalable_topic.rs`. `#[ignore]`d, which ADR-0046 otherwise forbids, and this is the documented exception. Every other e2e test asserts something about magnetar; this one asserts that apache/pulsar#26416 is absent, which no client behaviour can change and which no generally-available image has fixed — Docker Hub stops at 4.0.13 and 4.2.4, and the fixed 4.0.14 / 4.2.5 are unpublished. Left running on the `latest` default it would be permanently red in CI on a defect this repository cannot repair, which is the failure mode that turns a check into noise. The attribute carries the reason and the reproduce command, and the `latest` default is kept so it goes green by itself the day a fixed image ships. Verified across repeated runs rather than one cell, because the result is not a clean red/green: 4.0.4 red 3/3 (min -10 to -14), 4.2.4 (== `latest`) red 8/8 (min -4 to -18), and 5.0.0-M2 -- the only image carrying apache/pulsar#26289 + apache/pulsar#26422 -- green in 11 of 12, with the twelfth reaching `min=Some(-2) negatives=1`. The merged upstream fixes therefore shrink the leak by about two orders of magnitude without closing it, which is why the assertion is written against the invariant and not against a known-good image. The full table is in `docs/testing.md`. Signed-off-by: Florentin Dubois <[email protected]>
1 of 11 tasks
Radiancebobo
pushed a commit
to Radiancebobo/pulsar
that referenced
this pull request
…lly removed (apache#26422) Signed-off-by: Florentin Dubois <[email protected]> Co-authored-by: Lari Hotari <[email protected]>
4 of 5 tasks
nodece
pushed a commit
to ascentstream/pulsar
that referenced
this pull request
…lly removed (apache#26422) Signed-off-by: Florentin Dubois <[email protected]> Co-authored-by: Lari Hotari <[email protected]> (cherry picked from commit 5c078d8)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReviewersUh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedProjectsDevelopmentSuccessfully 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. |