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] Don't clear shared broker entry metadata when recycling a pooled message by sakshichitnis27 · Pull Request #27098 · apache/pulsar

Conversation

@sakshichitnis27

@sakshichitnis27 sakshichitnis27 commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Fixes #27076

Motivation

With poolMessages=true, the messages of a batch share the same BrokerEntryMetadata instance (ConsumerImpl.newSingleMessage passes the batch's reference to each message). MessageImpl.recycle() called clear() on that instance, so releasing one message also removed the broker publish time and index of the other messages from the same batch that were still in use.

I was able to reproduce this with a regression test: after releasing one of two pooled messages that share broker entry metadata, the other message reported hasBrokerPublishTime() == false.

Modifications

  • MessageImpl.recycle() now sets brokerEntryMetadata to null instead of clearing it, so the shared instance is no longer modified. A BrokerEntryMetadata is parsed per entry and isn't pooled, so nothing relies on it being cleared.
  • Added MessageImplTest#testReleaseKeepsBrokerMetadataOfPooledBatchSiblings, which releases the two messages of a batch in both orders and checks the broker publish time and index of the message that is still live.

Verifying this change

  • Make sure that the change passes the CI checks.

This change added tests and can be verified as follows:

  • The new test fails on master without the change and passes with it:
    ./gradlew :pulsar-client-original:test --tests "MessageImplTest"
  • I also ran ./gradlew :pulsar-client-original:test --tests "org.apache.pulsar.client.impl.*" and ./gradlew quickCheck locally.

Does this pull request potentially affect one of the following parts:

  • 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

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Sorry, something went wrong.

Uh oh!

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

All reactions
@sakshichitnis27
[fix][client] Don't clear shared broker entry metadata when recycling…
c367a5c
… a pooled message

With poolMessages=true, all messages of a batch share the same
BrokerEntryMetadata instance. MessageImpl.recycle() cleared that
instance, so releasing one message removed the broker timestamp and
index of the other messages from the same batch that were still in use.

Drop the reference in recycle() instead of clearing the shared instance.

Assisted-by: Claude Code
@sakshichitnis27
sakshichitnis27 marked this pull request as ready for review October 24, 2026 23:55
@sakshichitnis27 sakshichitnis27 mentioned this pull request Oct 24, 2026
[Bug] Releasing a pooled batch message clears broker metadata of live sibling messages #27076
Closed
@void-ptr974

void-ptr974 commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Thanks for the fix!

One small, non-blocking issue in the new test: pooled MessageImpl.create() retains the payload buffer, so message.release() leaves the test’s original buffer reference outstanding. Also, live.release() is skipped if an assertion fails. Keeping each buffer in a local variable, releasing the original reference after construction, and using finally for message cleanup would address both cases.

All reactions

Sorry, something went wrong.

Uh oh!

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

codelipenghui
codelipenghui reviewed Oct 26, 2026
View reviewed changes
Comment thread pulsar-client/src/test/java/org/apache/pulsar/client/impl/MessageImplTest.java Resolved

Uh oh!

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

sakshichitnis27 added 2 commits October 26, 2026 12:12
@sakshichitnis27
[fix][client] Release payload buffers in the pooled batch message test
fb5acf3
Pooled MessageImpl.create() retains the payload, so release the
reference owned by the test after creating each message and release
the messages that are still live in a finally block.

Assisted-by: Claude Code
@sakshichitnis27
Merge remote-tracking branch 'origin/master' into issue-27076-pooled-…
373277b
…broker-metadata
codelipenghui
codelipenghui approved these changes Oct 26, 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.

Thanks for addressing the test cleanup. The previous finding is resolved, and all 25 focused test cases passed at 373277b. LGTM.

Sorry, something went wrong.

Uh oh!

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

All reactions
@merlimat
merlimat merged commit 5188833 into apache:master Oct 26, 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 28, 2026
@sakshichitnis27 @lhotari
[fix][client] Don't clear shared broker entry metadata when recycling…
451c7ba
… a pooled message (#27098)

(cherry picked from commit 5188833)
@lhotari lhotari added release/5.0.2 cherry-picked/branch-5.0 labels Oct 28, 2026
This was referenced Nov 21, 2026
[improve][ci] Run CI for the 4.2.6 backports to branch-4.2 (do not merge) #27680
Closed
[improve][ci] Run CI for the 4.2.6 backports to branch-4.2 (do not merge) #27681
Closed
[improve][ci] Run CI for the 4.2.6 backports to branch-4.2 (do not merge) #27684
Closed
@lhotari lhotari added cherry-picked/branch-4.2 release/4.2.6 cherry-picked/branch-4.0 release/4.0.15 labels Nov 21, 2026
poorbarcode pushed a commit to poorbarcode/pulsar that referenced this pull request Nov 26, 2026
@sakshichitnis27 @lhotari
[fix][client] Don't clear shared broker entry metadata when recycling…
9a04ece
… a pooled message (apache#27098)

(cherry picked from commit 5188833)
poorbarcode pushed a commit to poorbarcode/pulsar that referenced this pull request Nov 26, 2026
@sakshichitnis27 @lhotari
[fix][client] Don't clear shared broker entry metadata when recycling…
f0fdb9c
… a pooled message (apache#27098)

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

Reviewers

@codelipenghui codelipenghui codelipenghui 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.2

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[Bug] Releasing a pooled batch message clears broker metadata of live sibling messages

Uh oh!

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

5 participants

@sakshichitnis27 @void-ptr974 @codelipenghui @merlimat @lhotari
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.