Repository navigation
fix(binding-kafka): fold produce entry claim block into trailing padding - #3540
Merged
jfallows merged 1 commit intoNov 24, 2026
Merged
Conversation
writeProduceEntryStart reserves a second trailersSizeMax block after the entry's trailers as scratch for the transform envelope, but writeProduceEntryFin only accounted for the trailers region in the entry's trailing paddingLen. The entry's sizeof() therefore ended short of the next entry by trailersSizeMax bytes, leaving a zero-filled gap between entries. Anything that walks the log by entry limit() (KafkaCachePartition.Node.clean, findAndAbortProducerId) landed inside the gap and read a zeroed entry whose deltaPosition of 0 is not the -1 sentinel. Compaction then read the empty delta file at position 0, a zero-length mapping, and the JVM crashed with SIGSEGV. Fold the claim block into the trailing paddingLen/padding in writeProduceEntryFin, as writeEntryFinish does for the populate path, so each entry is contiguous with the next. Add a test that walks produce entries by limit() and update the pinned produce entry bytes to the new padding length. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoYAZzKbDRpztRerQUz
jfallows
pushed a commit
to aklivity/mqtt-benchmark
that referenced
this pull request
Nov 24, 2026
…ess and evidence Repro scripts, crash logs and before/after results for the produce-side segment compaction crash fixed by aklivity/zilla#3540. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoYAZzKbDRpztRerQUz
jfallows
pushed a commit
to aklivity/mqtt-benchmark
that referenced
this pull request
Nov 24, 2026
* Run Zilla 2.8.0-rc8 by default 2.8.0-rc8 includes aklivity/zilla#3540, which fixes the JVM crash in the Kafka cache's produce-side segment compaction (aklivity/zilla#3536), and the QoS 2 fix from aklivity/zilla#3309. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Remove Zilla issue notes from the README and the QoS 2 delivery check Co-Authored-By: Claude Opus 5.5 <[email protected]> * Drop the stale shared subscription note and reword the lower connection rate scenarios Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
KafkaCachePartition.writeProduceEntryStartreserves a secondtrailersSizeMaxblock after an entry's trailers, used as scratch by the transform envelope.writeProduceEntryFindid not account for it in the entry's trailingpaddingLen, so a produce entry'ssizeof()endedtrailersSizeMaxbytes before the next entry, leaving a zero-filled gap between entries in the log.Code that walks the log by
limit()lands in that gap.KafkaCachePartition.Node.cleanread a zeroed entry there, sawdeltaPosition == 0rather than the-1sentinel, and read the delta file at position 0. That file is empty, so its mapping has address 0 and the JVM crashed with SIGSEGV (UnsafeBufferEx.getInt<-KafkaCacheDeltaFW.wrap<-KafkaCacheFile.readBytes<-Node.clean).findAndAbortProducerIdwalks the log the same way.This is not a mapped region read after
IoUtil.unmap(): the segment was alive and mapped, and the entry boundaries were wrong.The fix folds the claim block into the trailing
paddingLen/paddinginwriteProduceEntryFin, aswriteEntryFinishalready does for the populate path, so every entry is contiguous with the next. The on-disk layout is unchanged: trailers are stilllength + bytes + paddingLen + padding, and the padding is now accounted for.Evidence
segment.ms/min.cleanable.dirty.ratio), crashing 110-135 s after the publishers connected.size=1491 limit=1491, zero bytes from 1491 to 1746, and the next real entry at 1747. The 256-byte gap equalstrailersSizeMax.cleanthree times in that window (base offsets 0, 1223426 and 3058535).Tests
KafkaCachePartitionTest.shouldDelimitProduceEntriesByLimitwrites two produce entries and walks them bylimit(). Againstdevelopit fails on a deterministic assertion, with no JVM crash (expected:<360> but was:<296>, a 32-byte gap per entry); with the fix it passes.shouldWriteProduceEntryWithPinnedFileContentspinned the old, mis-delimited padding length (0x18). It now pins0x38, which includes the claim block../mvnw clean verifypasses forruntime/binding-kafkaandspecs/binding-kafka.spec.Existing segments on disk
Segments written before this change are never read back, so no handling for them is added. The cache does not reload segment files at startup:
KafkaCachePartitionstarts with an empty segment chain and its constructor only creates the directory (KafkaCachePartition.java:161-172for fetch,:212-226for produce). Nothing in the module lists or scans the cache directory.KafkaCachePartition.append(:283), whoseKafkaCacheFileconstructor callsmapCreateAppend, which deletes any file at that path before creating it (KafkaCacheFile.java:359-368). The read-onlyKafkaCacheSegmentconstructor is used only byfreeze()on files just written (KafkaCacheSegment.java:216).KafkaCachePartition.java:196). Fetch and produce directories are not wiped, so leftover files with other base offsets stay on disk unread until overwritten.Introduced by
91144fa5d(#2457, 2026-08-30) added the claim block towriteProduceEntryStartfor every produce entry (not only entries with a transform). It leftwriteProduceEntryFinunchanged apart from a new flag.trailersClaimMarkis present in tag 2.4.0 and absent from 2.3.0 and 1.3.4.Fixes #3536
🤖 Generated with Claude Code
https://claude.ai/code/session_01SiHVoYAZzKbDRpztRerQUz