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][ml] Materialize compressed ManagedCursorInfo before releasing the decompressed buffer by M-Schwab · Pull Request #27050 · apache/pulsar

Conversation

@M-Schwab

@M-Schwab M-Schwab commented Oct 22, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

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:

  • Added ManagedCursorInfoMetadataTest.testDecodeCursorInfoWithProperties.
  • Manually verified with the reproduction script from [Bug] Topic can't be loaded once a cursor with properties is stored compressed (IllegalReferenceCountException: refCnt: 0) #27049 against bin/pulsar standalone built from this branch.

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
@M-Schwab
[fix][ml] Materialize compressed ManagedCursorInfo before releasing t…
e536a39
…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 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
lhotari
lhotari approved these changes Oct 22, 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 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
All reactions
  • 👍 1 reaction
@lhotari lhotari added release/5.0.1 release/4.2.6 labels Oct 22, 2026
@lhotari lhotari added this to the 5.1.0 milestone Oct 22, 2026
This was referenced Oct 22, 2026
[fix][broker] Reply to failed GetLastMessageId with the original request id #27053
Merged
[fix][proxy] Copy GetTopicsOfNamespace properties before the broker connection completes #27055
Merged
[Bug] Topic can't be loaded once a cursor with properties is stored compressed (IllegalReferenceCountException: refCnt: 0) #27049
Closed
@M-Schwab
Merge branch 'master' into fix/ml-materialize-compressed-cursor-info
4dac2be
@M-Schwab

M-Schwab commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

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.

All reactions

Sorry, something went wrong.

Uh oh!

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

@lhotari

lhotari commented Oct 22, 2026

Copy link
Copy Markdown
Member

@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
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

lhotari pushed a commit that referenced this pull request Oct 22, 2026
@M-Schwab @lhotari
[fix][ml] Materialize compressed ManagedCursorInfo before releasing t…
9ef1a62
…he decompressed buffer (#27050)
@M-Schwab

M-Schwab commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Ah, OK, sorry about that.

All reactions

Sorry, something went wrong.

Uh oh!

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

@lhotari

lhotari commented Oct 22, 2026

Copy link
Copy Markdown
Member

Ah, OK, sorry about that.

Np. Solved that by cherry-picking the commit to branch-5.0 before this was merged so that I don't have to wait for our slow CI to run. I've published 5.0.1-candidate-2 with this change included. Currently in voting, details at https://lists.apache.org/thread.html/0wv6ft3r3v0llc6kv07rmynyrk72nhkr.

M-Schwab 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.

@merlimat
merlimat merged commit c77ffb7 into apache:master Oct 22, 2026
43 checks passed

Uh oh!

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

@lhotari lhotari added the cherry-picked/branch-5.0 label Oct 23, 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 the cherry-picked/branch-4.2 label Nov 21, 2026
poorbarcode pushed a commit to poorbarcode/pulsar that referenced this pull request Nov 26, 2026
@M-Schwab @lhotari
[fix][ml] Materialize compressed ManagedCursorInfo before releasing t…
0a966ec
…he decompressed buffer (apache#27050)

(cherry picked from commit c77ffb7)
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.2 cherry-picked/branch-5.0 release/4.2.6 release/5.0.1

Projects

None yet

Milestone

5.1.0

Development

Successfully merging this pull request may close these issues.

[Bug] Topic can't be loaded once a cursor with properties is stored compressed (IllegalReferenceCountException: refCnt: 0)

Uh oh!

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

3 participants

@M-Schwab @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.