Repository navigation
fix(inkless:consolidation): skip the diskless supplement when the local read ends mid-batch [KC-876] - #911
Open
viktorsomogyi wants to merge 2 commits into
Open
fix(inkless:consolidation): skip the diskless supplement when the local read ends mid-batch [KC-876]#911viktorsomogyi wants to merge 2 commits into
viktorsomogyi wants to merge 2 commits into
Conversation
…al read ends mid-batch [KC-876] A byte-limited local read of a consolidating partition can end inside a batch. The batch iterator drops that partial tail, so the supplement starts at the partial batch's base offset. The merge still keeps the partial bytes, and the response holds a truncated batch in front of the diskless batches. The consumer reads the partial header, runs into the diskless bytes, and fails the CRC check. The local log isn't frozen at the seal, because the consolidation fetcher keeps appending to it. The log end offset captured at routing can therefore be stale, which lets the exhaustion guard pass. Skip the supplement when the complete batches don't account for all local bytes. The partial batch then stays the last thing in the response, and the consumer re-fetches from the last complete batch. Testing Add a `ReplicaManagerInklessTest` case that ends the local read inside a batch past the stale log end offset. The test fails without the guard. Assisted-by: Claude Sonnet 5.5
viktorsomogyi
force-pushed
the
svv/kc-876-partial-batch
branch
from
November 27, 2026 14:08
2cfd8b3 to
39284c2
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The change adds a redundant full-batch scan to each local read, repeating file-channel header reads even when supplementation is ineligible; combine the traversals and skip unnecessary work.
1 open issue
What changed in this PR
This PR prevents consumer CRC failures during consolidation by skipping diskless supplements when a local read ends inside a batch. It leaves the DelayedFetch log-end-offset capture unchanged.
Changes:
- Check that complete batches account for all local record bytes before supplementing.
- Add a regression test for a partial trailing batch with a stale routing-time log end offset.
| File | Description |
|---|---|
core/src/test/scala/unit/kafka/server/ReplicaManagerInklessTest.scala |
Tests that a local read ending mid-batch produces no supplement. |
core/src/main/scala/kafka/server/ReplicaManager.scala |
Adds a batch-boundary guard before requesting a diskless supplement. |
Review effort: Balanced
…e supplement [KC-876] The batch-boundary check added a second pass over each local read, on top of the `lastBatch()` walk. For a file-backed read, every pass costs a channel read per batch, even when no supplement can run. Find the last batch and total the complete bytes in one pass. Run the pass only after the cheap checks (usable local read, remaining byte budget) leave a supplement possible. Testing Run `ReplicaManagerInklessTest` and `DelayedFetchTest` with no failures. Assisted-by: Claude Sonnet 5.5
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.
Why
A byte-limited local read of a consolidating partition can end inside a batch. The batch iterator drops that partial tail, so the supplement starts at the partial batch's base offset. The merge still keeps the partial bytes, so the response holds a truncated batch in front of the diskless batches. The consumer reads the partial header, runs into the diskless bytes, and fails the CRC check.
The local log isn't frozen at the seal, because the consolidation fetcher keeps appending to it. The log end offset that
DelayedFetchcaptures at routing can therefore be stale, which lets the exhaustion guard pass.The committed data isn't lost, but the consumer can't make progress until a later fetch avoids the same shape.
What changes
buildConsolidationSupplementFetchInfosskips the supplement when the complete batches don't account for all local bytes. The partial batch then stays the last thing in the response, where it's harmless, and the consumer re-fetches from the last complete batch.This change doesn't move the log end offset that
DelayedFetch.onCompleteuses. That idea from the ticket is a separate change.Test plan
testBuildConsolidationSupplementFetchInfosSkipsWhenLocalReadEndsMidBatchtoReplicaManagerInklessTest. The test fails without the guard and passes with it.ReplicaManagerInklessTest(321 tests) andDelayedFetchTest(5 tests) with no failures.make valewith no alerts.Fixes KC-876.
🤖 Generated with Claude Code