GeezerVison is showing github.com — [fix][ml] Materialize compressed ManagedCursorInfo before releasing the decompressed buffer by M-Schwab · Pull Request #27050 · apache/pulsar
Conversation
M-Schwab
commented
Oct 22, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Fixes #27049
Motivation
Once a cursor's info is larger than managedCursorInfoCompressionThresholdInBytes (16 KiB by default, with managedCursorInfoCompressionType=LZ4), it is stored compressed, and after the next unload the topic can no longer be loaded. Producers and consumers fail with BrokerPersistenceError ... MetaStoreException: io.netty.util.IllegalReferenceCountException: refCnt: 0, and internalStats and topic deletion return HTTP 500.
MetaStoreImpl.parseManagedCursorInfo releases the decompressed buffer before returning, but LightProto reads string fields lazily from that buffer, so cursor recovery later reads property names from a released buffer. parseManagedLedgerInfo avoids this by calling materialize() first, so I've copied that flow to the cursor parsing.
This can be triggered relatively easily with message deduplication: the pulsar.dedup cursor stores one property per producer, so a topic with ~800+ recent producers crosses the 16 KiB threshold.
Modifications
- Call
ManagedCursorInfo.materialize() before releasing the decompressed buffer in MetaStoreImpl.parseManagedCursorInfo, matching parseManagedLedgerInfo.
- Add test
ManagedCursorInfoMetadataTest.testDecodeCursorInfoWithProperties, which round-trips a ManagedCursorInfo with 100 LongProperty and 100 StringProperty entries through compression for every compression type, then reads the string fields after the decompressed buffer has been released.
Verifying this change
- Make sure that the change passes the CI checks.
This change added tests and can be verified as follows:
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.
…he decompressed buffer
### Motivation
When a cursor's info exceeds managedCursorInfoCompressionThresholdInBytes it
is stored compressed. MetaStoreImpl.parseManagedCursorInfo parses the
decompressed ByteBuf with LightProto, whose string fields are read lazily
from the buffer, and then releases the buffer before returning.
ManagedCursorImpl later reads the cursor's StringProperty and LongProperty
names from the released buffer and fails with
IllegalReferenceCountException: refCnt: 0, so the topic can no longer be
loaded. parseManagedLedgerInfo already materializes before releasing;
parseManagedCursorInfo did not.
### Modifications
- Call ManagedCursorInfo.materialize() before releasing the decompressed
buffer in MetaStoreImpl.parseManagedCursorInfo.
- Add a test that decodes compressed cursor info with properties and
cursor properties for every compression type, and reads the string
fields after the buffer has been released.
Fixes apache#27049
Assisted-by: Claude Code (Claude Opus 5.5)
M-Schwab
changed the title
[fix][ml] Materialize compressed ManagedCursorInfo before releasing the decompressed buffer
[fix][ml] Materialize compressed ManagedCursorInfo before releasing the decompressed buffer
Oct 22, 2026
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 this issue! LGTM
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
M-Schwab reacted with thumbs up emoji
This was referenced Oct 22, 2026
Thanks for addressing this issue! LGTM
No thank you. Overall, going from 3.x to 5 has been quite good, so I appreciate all of the work that's gone into puslar.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@M-Schwab btw. Please don't push more changes if master moves ahead. I'm currently waiting for CI to complete so that I can start 5.0.1-candidate-2 with this change included since this fixes a major regression. The problem occurs also with individual acknowledgements since the defaults were changed in #25992. Most users will hit this same problem while upgrading to 5.0.x so I'd like to get this delivered in 5.0.1 on Monday or Tuesday next week.
|
M-Schwab reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Ah, OK, sorry about that.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
M-Schwab reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Nov 21, 2026
Reviewers
lhotari
lhotari approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
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.
|