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] [client] chunked message uuid-queue never removes entries on successful processing by programmerahul · Pull Request #26658 · apache/pulsar

Conversation

@programmerahul

@programmerahul programmerahul commented Sep 19, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Fixes: #26676

Motivation

uuid-queue pendingChunkedMessageUuidQueue doesn't remove entries after a chunked message is processed. So after processing 1M chunked messages, this queue has 1M entries.
This can be reproduced easily by sending chunked message and on consumer end simply acking those. So once the consumer processs 1M message , this queue also reached that size.

The larger issue with this is that , after processing of first chunked message, the expiry mechanism removeExpireIncompleteChunkedMessages() can't work for any incomplete message, because the logic will always find the first uuid from blockingQueue, but not in the chunkedMessageMap.

Modifications

Remove the uuid from quue when the chunked message is completely received

Verifying this change

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

This change added tests and can be verified as follows:

  • Added a test-case for this

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
Rahul Prasad and others added 2 commits September 20, 2026 00:24
Rahul Prasad
uuid-queue
602cf88
@programmerahul
Merge branch 'master' into fix/chunked-message-uuid-queue-leak
31ae0f5
@programmerahul

programmerahul commented Sep 19, 2026

Copy link
Copy Markdown
Contributor Author

@lhotari Please review

All reactions

Sorry, something went wrong.

Uh oh!

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

programmerahul added 3 commits September 20, 2026 01:59
@programmerahul
Merge branch 'master' into fix/chunked-message-uuid-queue-leak
fa5b1bf
@programmerahul
Merge branch 'master' into fix/chunked-message-uuid-queue-leak
b3de211
@programmerahul
Merge branch 'master' into fix/chunked-message-uuid-queue-leak
eeec268
@programmerahul

programmerahul commented Sep 20, 2026

Copy link
Copy Markdown
Contributor Author

The larger issue with this is that , after processing of first chunked message, the expiry mechanism removeExpireIncompleteChunkedMessages() can't work for any incomplete message, because the logic will always find the first uuid from blockingQueue, but not in the chunkedMessageMap.

All reactions

Sorry, something went wrong.

Uh oh!

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

@programmerahul
Merge branch 'master' into fix/chunked-message-uuid-queue-leak
27a178e
@programmerahul

programmerahul commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

@poorbarcode @void-ptr974 @merlimat @codelipenghui @BewareMyPower @Demogorgon314 please review this PR. This is easily reproducible bug, and as a side-effect of it, the expiry mechanism doesn't work

All reactions

Sorry, something went wrong.

Uh oh!

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

programmerahul and others added 6 commits September 22, 2026 19:46
@programmerahul
Merge branch 'master' into fix/chunked-message-uuid-queue-leak
14197a9
@programmerahul
Merge branch 'master' into fix/chunked-message-uuid-queue-leak
23559b7
@programmerahul
Merge branch 'master' into fix/chunked-message-uuid-queue-leak
dde2196
@programmerahul
Merge branch 'master' into fix/chunked-message-uuid-queue-leak
6fe293d
Rahul Prasad
merge master
c16f748
Rahul Prasad
added a testcase for expiry message mechanism being stuck
f216708
@programmerahul

programmerahul commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

The larger issue with this is that , after processing of first chunked message, the expiry mechanism removeExpireIncompleteChunkedMessages() can't work for any incomplete message, because the logic will always find the first uuid from blockingQueue, but not in the chunkedMessageMap.

I have added a testcase for this scenario

All reactions

Sorry, something went wrong.

Uh oh!

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

@programmerahul
Merge branch 'master' into fix/chunked-message-uuid-queue-leak
ae57339
@lhotari lhotari mentioned this pull request Oct 1, 2026
[improve][client] Replace chunked-message queue and counter with an insertion-ordered map in ConsumerImpl #26689
Open
1 of 11 tasks
lhotari
lhotari reviewed Oct 1, 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 tracking this down and for including the follow-on observation about expiry.

The bug is real and the fix is correct for the normal completion path: ConsumerImpl.java:1548 now drops the completed uuid from pendingChunkedMessageUuidQueue. I removed that line locally and both new tests fail (queue stays at 50 entries; the incomplete "stuck" context is never expired), and with it they pass. GrowableArrayBlockingQueue.remove(Object) takes both queue locks so it is safe against the expiry thread, and the O(n) scan is bounded by the number of in-flight chunked messages, so I am not concerned about cost.

One point I would like addressed or discussed: this fixes one way a completed/discarded uuid can be left at the head of the queue, but removeExpireIncompleteChunkedMessages still returns on the first uuid whose context is gone (ConsumerImpl.java:3207-3216), so any other path that leaves a stale uuid behind reintroduces the exact symptom described in the PR. See the inline comment for the two paths I confirmed. Making the expiry loop drop stale heads and continue would address the whole class, and the two small cases could be covered by tests.

Minor: the PR description says the test is added but does not mention the expiry effect that the second test covers; worth adding to the Motivation.

Sorry, something went wrong.

Uh oh!

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

programmerahul reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java Resolved

Uh oh!

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

@lhotari lhotari added the release/5.0.1 label Oct 1, 2026
Rahul Prasad and others added 5 commits October 2, 2026 15:34
Rahul Prasad
updated expire loop and added testcase for that
27e45e5
Rahul Prasad
Merge branch 'master' into fix/chunked-message-uuid-queue-leak
803efd8
@programmerahul
Merge branch 'master' into fix/chunked-message-uuid-queue-leak
e8d861c
@programmerahul
Merge branch 'master' into fix/chunked-message-uuid-queue-leak
9f9d12f
@programmerahul
Merge branch 'master' into fix/chunked-message-uuid-queue-leak
6eb8ed6
Denovo1998
Denovo1998 approved these changes Oct 9, 2026
View reviewed changes
@programmerahul
Merge branch 'master' into fix/chunked-message-uuid-queue-leak
60e2004
@programmerahul

programmerahul commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @Denovo1998 for reviewing and approving the PR

All reactions

Sorry, something went wrong.

Uh oh!

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

@programmerahul
Merge branch 'master' into fix/chunked-message-uuid-queue-leak
7298171
lhotari
lhotari reviewed 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.

Thanks for the update. The expiry loop now skips a stale head and the new tests cover both cases I raised. One small thing to fix in the loop: it should remove the uuid it looked at, not whatever is at the head. See the inline comment.

Sorry, something went wrong.

Uh oh!

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

programmerahul reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java Resolved

Uh oh!

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

codelipenghui
codelipenghui requested changes Oct 13, 2026
View reviewed changes

@codelipenghui codelipenghui left a comment

Copy link
Copy Markdown
Contributor

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.

The completion-path cleanup fixes the reported UUID leak, and skipping stale heads is the right direction. However, the new poll() in the stale-head branch can remove an unrelated live UUID during concurrent completion. I independently reproduced the race already noted by @lhotari and would like it fixed before merging.

Validation on 7298171, using focused Gradle tests on Java 21 with retries disabled:

  • All three added regression tests passed at the PR head.
  • With the production fix reverted (retaining only the test accessor), all three failed for the expected reasons: 50 completed UUIDs remained queued, and both expiry scenarios stalled.
  • A temporary controlled real-message concurrency test failed at the PR head: B remained in chunkedMessagesMap, but its UUID had disappeared from the queue.
  • Replacing the stale-head poll() with remove(messageUUID) made that reproducer and all three PR tests pass.

Please include a deterministic regression for this interleaving. A non-head completion case (A0, B0, B1, leaving A incomplete) would also strengthen coverage. The full suite was not run, and all temporary source changes were restored.

Sorry, something went wrong.

Uh oh!

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

programmerahul reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConsumerImpl.java Resolved

Uh oh!

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

Rahul Prasad and others added 3 commits October 14, 2026 01:13
Rahul Prasad
used remove instead of poll in expiry and added testcases
32a0c45
Rahul Prasad
Merge branch 'master' into fix/chunked-message-uuid-queue-leak
0d690c5
@programmerahul
Merge branch 'master' into fix/chunked-message-uuid-queue-leak
613493d
@programmerahul

programmerahul commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

I have addressed the comments: @lhotari @codelipenghui Please review.

All reactions

Sorry, something went wrong.

Uh oh!

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

codelipenghui
codelipenghui reviewed Oct 13, 2026
View reviewed changes

@codelipenghui codelipenghui left a comment

Copy link
Copy Markdown
Contributor

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.

The previous production race is addressed. The new race regression passes at 613493d and fails as expected when the old poll() is restored. One test-only buffer cleanup issue remains below.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread pulsar-broker/src/test/java/org/apache/pulsar/client/impl/MessageChunkingTest.java Resolved

Uh oh!

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

Rahul Prasad and others added 2 commits October 14, 2026 01:57
Rahul Prasad
updated testcase to release memory
d67c2a0
@programmerahul
Merge branch 'master' into fix/chunked-message-uuid-queue-leak
9b851b3
codelipenghui
codelipenghui approved these changes Oct 13, 2026
View reviewed changes

@codelipenghui codelipenghui left a comment

Copy link
Copy Markdown
Contributor

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.

Both previous findings are addressed at 9b851b3: UUID-specific removal fixes the stale-head race, and the regression test now explicitly expires B, verifies its buffer is released, and cleans up remaining buffers on failure paths.

All 23 chunking test cases passed with retries disabled and -PtestExitJvmOnLeak=true, with no Netty leak diagnostics. The full repository suite was not run.

No actionable findings identified within the reviewed scope.

Sorry, something went wrong.

Uh oh!

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

programmerahul reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@programmerahul
Merge branch 'master' into fix/chunked-message-uuid-queue-leak
a53cebd
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. The expiry loop now removes the uuid it inspected, so it can no longer drop a live entry that the receive thread did not touch. The two new tests cover the race and the non-head completion case.

Sorry, something went wrong.

Uh oh!

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

All reactions
@codelipenghui codelipenghui added this to the 5.1.0 milestone Oct 14, 2026
@codelipenghui codelipenghui added release/4.2.6 release/4.0.15 type/bug The PR fixed a bug or issue reported a bug labels Oct 14, 2026
@codelipenghui codelipenghui assigned programmerahul Oct 14, 2026
@lhotari

lhotari commented Oct 14, 2026

Copy link
Copy Markdown
Member

@programmerahul Checkstyle fails. Please run ./gradlew quickCheck before pushing changes. Coding agents usually do this and fix issues if you ask since https://github.com/apache/pulsar/blob/master/AGENTS.md references https://github.com/apache/pulsar/blob/master/CONTRIBUTING.md#building which contains the commands.
There's also https://pulsar.apache.org/contribute/setup-building/#build with more details.
You can also run the complete Pulsar CI pipeline in your fork to test changes without waiting for project maintainers to run CI in this PR. Explained in https://github.com/apache/pulsar/blob/master/CONTRIBUTING.md#running-the-full-ci-pipeline-personal-ci and https://pulsar.apache.org/contribute/personal-ci/

programmerahul reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

Rahul Prasad added 2 commits October 15, 2026 01:30
Rahul Prasad
checkstyle fix
1e2e300
Rahul Prasad
Merge branch 'master' into fix/chunked-message-uuid-queue-leak
f717101
@programmerahul

programmerahul commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

@programmerahul Checkstyle fails. Please run ./gradlew quickCheck before pushing changes. Coding agents usually do this and fix issues if you ask since https://github.com/apache/pulsar/blob/master/AGENTS.md references https://github.com/apache/pulsar/blob/master/CONTRIBUTING.md#building which contains the commands. There's also https://pulsar.apache.org/contribute/setup-building/#build with more details. You can also run the complete Pulsar CI pipeline in your fork to test changes without waiting for project maintainers to run CI in this PR. Explained in https://github.com/apache/pulsar/blob/master/CONTRIBUTING.md#running-the-full-ci-pipeline-personal-ci and https://pulsar.apache.org/contribute/personal-ci/

Thanks, I have now fixed the checkstyle. Also all CI passed in my personal repo pr: programmerahul#2

All reactions

Sorry, something went wrong.

Uh oh!

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

@codelipenghui
codelipenghui merged commit b625a9f into apache:master Oct 15, 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
@programmerahul Rahul Prasad @lhotari
[fix] [client] chunked message uuid-queue never removes entries on su…
58d08b8
…ccessful processing (#26658)

Co-authored-by: Rahul Prasad <[email protected]>
(cherry picked from commit b625a9f)
@lhotari lhotari added the cherry-picked/branch-5.0 label Oct 15, 2026
@SongOf SongOf mentioned this pull request Oct 15, 2026
[fix][client] Serialize chunked-message bookkeeping to fix use-after-free and count/queue drift #26084
Merged
2 of 15 tasks
lhotari pushed a commit that referenced this pull request Oct 16, 2026
@programmerahul Rahul Prasad @lhotari
[fix] [client] chunked message uuid-queue never removes entries on su…
2d798d7
…ccessful processing (#26658)

Co-authored-by: Rahul Prasad <[email protected]>
(cherry picked from commit b625a9f)
@lhotari lhotari added cherry-picked/branch-4.2 cherry-picked/branch-4.0 labels Oct 17, 2026
scmi-c8y pushed a commit to scmi-c8y/pulsar that referenced this pull request Oct 30, 2026
@programmerahul Rahul Prasad @lhotari
[fix] [client] chunked message uuid-queue never removes entries on su…
2d615be
…ccessful processing (apache#26658)

Co-authored-by: Rahul Prasad <[email protected]>
(cherry picked from commit b625a9f)
nodece pushed a commit to ascentstream/pulsar that referenced this pull request Nov 16, 2026
@programmerahul Rahul Prasad @nodece
[fix] [client] chunked message uuid-queue never removes entries on su…
5a71831
…ccessful processing (apache#26658)

Co-authored-by: Rahul Prasad <[email protected]>
(cherry picked from commit b625a9f)
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
@codelipenghui codelipenghui codelipenghui approved these changes
@Denovo1998 Denovo1998 Denovo1998 approved these changes

Uh oh!

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

Assignees

@programmerahul programmerahul

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 type/bug The PR fixed a bug or issue reported a bug

Projects

None yet

Milestone

5.1.0

Development

Successfully merging this pull request may close these issues.

[Bug] chunked message uuid-queue never removes entries on successful processing

Uh oh!

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

4 participants

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