GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [fix][broker] Prevent stale consumer removal from removing replacements by Denovo1998 · Pull Request #26652 · apache/pulsar

Conversation

@Denovo1998

@Denovo1998 Denovo1998 commented Sep 19, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Follow-up to #26422.
Related to #26289.

Motivation

A delayed removal of an old consumer can match a replacement consumer through Consumer.equals(), even though they are different instances. This can remove the replacement from dispatcher membership and debit the old consumer's unacknowledged messages again. For Key_Shared subscriptions, the stale removal can also remove the replacement from the selector and prevent further delivery.

Modifications

  • Require the exact registered consumer instance before removing dispatcher membership or debiting its unacknowledged messages.
  • Remove consumer list entries by identity while maintaining priority counts, including defensive cleanup and failed-add cleanup.
  • Protect replacement consumers from stale AUTO_SPLIT removals.
  • Preserve cleanup for STICKY additions that complete after dispatcher removal. Remove selector ranges and classic recently-joined records by identity.
  • Apply the changes to both classic and newer persistent dispatchers.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Denovo1998
[fix][broker] Prevent stale consumer removal from removing replacements
dc7dcf3
@merlimat
merlimat requested a review from lhotari September 19, 2026 15:48
lhotari
lhotari requested changes Sep 19, 2026
View reviewed changes

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks for protecting replacement consumers across both dispatcher implementations. The identity checks look sound for completed additions, but the new Key_Shared early return drops cleanup for a STICKY addition that completes after removal. Please preserve that cleanup and cover the delayed-add case.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread .../apache/pulsar/broker/service/persistent/PersistentStickyKeyDispatcherMultipleConsumers.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@Denovo1998
Ensure sticky dispatcher cleanup handles unregistered consumers and s…
cc0311f
…elector removal uses identity.
@Denovo1998
Denovo1998 requested a review from lhotari September 20, 2026 13:38
@lhotari lhotari added the release/5.0.1 label Oct 1, 2026
lhotari
lhotari approved these changes Oct 13, 2026
View reviewed changes

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM. The one open point is handled in cc0311f. STICKY consumers now run the full removal path even when they are no longer registered, so a late selector addition is cleaned up on the repeated close. The selector and the Classic recently-joined map remove by identity, so an equal replacement keeps its range. The new test covers the late addition and the repeated close.

The branch now conflicts with master, so it needs a merge of master before it can go in.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Denovo1998
Merge apache/pulsar master into fix-consumer-removal-accounting
b816e8f
@Denovo1998

Denovo1998 commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

LGTM. The one open point is handled in cc0311f. STICKY consumers now run the full removal path even when they are no longer registered, so a late selector addition is cleaned up on the repeated close. The selector and the Classic recently-joined map remove by identity, so an equal replacement keeps its range. The new test covers the late addition and the repeated close.

The branch now conflicts with master, so it needs a merge of master before it can go in.

Okay, conflict processed.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

lhotari
lhotari approved these changes Oct 14, 2026
View reviewed changes

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM. Thanks for merging master. The merge dropped the Classic dispatcher edits because master removed those classes, and nothing in the tree refers to them any more. The remaining fix is unchanged: the STICKY removal path in PersistentStickyKeyDispatcherMultipleConsumers.java:345-356 and the identity-based selector removal still cover the late addition and the repeated close, and the new tests are intact.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@merlimat
merlimat merged commit 668c16d into apache:master Oct 14, 2026
43 checks passed

Uh oh!

There was an error while loading. Please reload this page.

lhotari pushed a commit that referenced this pull request Oct 15, 2026
@Denovo1998 @lhotari
[fix][broker] Prevent stale consumer removal from removing replacemen…
8a2342f
…ts (#26652)

(cherry picked from commit 668c16d)
@lhotari lhotari added cherry-picked/branch-5.0 release/4.2.6 release/4.0.15 labels Oct 15, 2026
lhotari pushed a commit that referenced this pull request Oct 16, 2026
@Denovo1998 @lhotari
[fix][broker] Prevent stale consumer removal from removing replacemen…
93ea0ba
…ts (#26652)

(cherry picked from commit 668c16d)
@lhotari lhotari added cherry-picked/branch-4.2 cherry-picked/branch-4.0 labels Oct 17, 2026
This was referenced Oct 22, 2026
[improve] [test] Add a test to verify no orphan consumers if release lock caused by checkConnectionLiveness #21498
Closed
[fix][broker] The offline consumer is not removed from the consumerList #14970
Closed
scmi-c8y pushed a commit to scmi-c8y/pulsar that referenced this pull request Oct 30, 2026
@Denovo1998 @lhotari
[fix][broker] Prevent stale consumer removal from removing replacemen…
3bc1b06
…ts (apache#26652)

(cherry picked from commit 668c16d)
nodece pushed a commit to ascentstream/pulsar that referenced this pull request Nov 16, 2026
@Denovo1998 @nodece
[fix][broker] Prevent stale consumer removal from removing replacemen…
6bc438c
…ts (apache#26652)

(cherry picked from commit 668c16d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@lhotari lhotari lhotari approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

cherry-picked/branch-4.0 cherry-picked/branch-4.2 cherry-picked/branch-5.0 release/4.0.15 release/4.2.6 release/5.0.1

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@Denovo1998 @lhotari @merlimat
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.