Skip to content

KAFKA-20726: Don't reuse the BufferSupplier in kraft state machine#22678

Open
0xffff-zhiyan wants to merge 1 commit into
apache:trunkfrom
0xffff-zhiyan:fix-dont-reuse-buffersupplier
Open

KAFKA-20726: Don't reuse the BufferSupplier in kraft state machine#22678
0xffff-zhiyan wants to merge 1 commit into
apache:trunkfrom
0xffff-zhiyan:fix-dont-reuse-buffersupplier

Conversation

@0xffff-zhiyan

Copy link
Copy Markdown
Contributor

KRaftControlRecordStateMachine reused a single BufferSupplier across all reads. The supplier returned by BufferSupplier.create() caches ByteBuffers by capacity without eviction, so the cached buffers lived as long as the state machine and consumed memory unboundedly.

Create a fresh BufferSupplier per read in maybeLoadLog() and maybeLoadSnapshot() instead, allowing it to be released once the read completes.

KRaftControlRecordStateMachine reused a single BufferSupplier across all
reads. The supplier returned by BufferSupplier.create() caches ByteBuffers
by capacity without eviction, so the cached buffers lived as long as the
state machine and consumed memory unboundedly.

Create a fresh BufferSupplier per read in maybeLoadLog() and
maybeLoadSnapshot() instead, allowing it to be released once the read
completes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added triage PRs from the community kraft small Small PRs labels Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kraft small Small PRs triage PRs from the community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant