Skip to content

[fix][ml] Reset messageMetadataInitialized when recycling RangeCacheEntryWrapper - #25987

Merged
lhotari merged 1 commit into
apache:masterfrom
merlimat:mmerli/fix-range-cache-wrapper-recycle
Jun 10, 2026
Merged

[fix][ml] Reset messageMetadataInitialized when recycling RangeCacheEntryWrapper#25987
lhotari merged 1 commit into
apache:masterfrom
merlimat:mmerli/fix-range-cache-wrapper-recycle

Conversation

@merlimat

@merlimat merlimat commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Motivation

RangeCacheEntryWrapper.recycle() resets all wrapper fields except messageMetadataInitialized. Once a wrapper has served a cache hit (which sets the flag in getValueInternal), every entry later stored in that recycled wrapper instance inherits messageMetadataInitialized=true, so getValueInternal() skips the lazy EntryImpl.initializeMessageMetadataIfNeeded() call.

After recycler warm-up, cache hits return entries whose message metadata was never parsed, and each dispatcher falls back to Commands.peekAndCopyMessageMetadata — a full metadata parse plus a MessageMetadata copy per entry per subscription. This silently defeats the parse-once-per-cached-entry optimization, with the cost multiplied by subscription fan-out.

Modifications

Reset messageMetadataInitialized in recycle(), matching the reset of the other wrapper fields. recycle() is the wrapper's only return-to-pool path, so this fully restores the intended lazy-init behavior.

…ntryWrapper

The flag was never cleared on recycle, so any wrapper that had served a
cache hit kept messageMetadataInitialized=true for every entry it was
later reused for. getValueInternal then skipped the lazy
initializeMessageMetadataIfNeeded call, and cache hits returned entries
with null metadata, forcing each dispatcher to re-parse the message
metadata per entry per subscription.
@lhotari lhotari added this to the 5.0.0-M1 milestone Jun 10, 2026
@lhotari
lhotari merged commit 98bac65 into apache:master Jun 10, 2026
83 of 86 checks passed
lhotari pushed a commit that referenced this pull request Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants