Repository navigation
fix(inkless:consolidation): skip the diskless supplement when the local read ends mid-batch [KC-876] - #911
Merged
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
jeqo
reviewed
Nov 30, 2026
Contributor
There was a problem hiding this comment.
LGTM, just a couple of suggestions before approving.
…cover FileRecords [KC-876] Skip the scan of a local read that is empty, and cover the behavior that the previous commit left unpinned. Add a `FileRecords` test that cuts the read inside a batch body and inside a batch header, because production local reads return `FileRecords` and `FileLogInputStream` handles each cut separately. Add a test that spies on `batches()` to assert zero scans when the budget is exhausted or the read is redirected, and one scan when the read is eligible. Testing Run `ReplicaManagerInklessTest` and `DelayedFetchTest` with no failures. The new tests fail when the scan runs eagerly or ignores the batch boundary. Assisted-by: Claude Sonnet 5.5
jeqo
approved these changes
Dec 2, 2026
This was referenced Dec 3, 2026
This was referenced Dec 3, 2026
gqmelo
added a commit
that referenced
this pull request
Dec 4, 2026
…branch 0.53 is the first release of `inkless-4.4`, so the branch joins the active table in `RELEASES.md`. The cherry-pick guide now places main at the 4.4 branch point and records the adaptations of this round: the SpotBugs exclude on 4.3, and the `forwarded` argument and the reassignment completion rule on 4.2 and 4.1. `ca375e2131` reached `main` inside the upstream sync merge #897, so `branch-consistency.sh` didn't list it, and the 4.1, 4.2, and 4.3 release-prep PRs failed `Compile and Check Java` without it. The guide now shows how to find Inkless commits inside a sync merge. The 4.1 session log first listed the hashes of the release-branch cherry-picks. The session template and the guide's agent prompt now ask for the hashes of the commits on main, as the other logs list them. The session logs record the cherry-pick of #882 through #927 to `inkless-4.1`, `inkless-4.2`, and `inkless-4.3`, and of #911 through #927 to `inkless-4.4`, with the follow-up pick of `ca375e2131` and the 4.3 jOOQ fix. Assisted-by: Claude Opus 5.5
jeqo
pushed a commit
that referenced
this pull request
Dec 4, 2026
…branch (#939) 0.53 is the first release of `inkless-4.4`, so the branch joins the active table in `RELEASES.md`. The cherry-pick guide now places main at the 4.4 branch point and records the adaptations of this round: the SpotBugs exclude on 4.3, and the `forwarded` argument and the reassignment completion rule on 4.2 and 4.1. `ca375e2131` reached `main` inside the upstream sync merge #897, so `branch-consistency.sh` didn't list it, and the 4.1, 4.2, and 4.3 release-prep PRs failed `Compile and Check Java` without it. The guide now shows how to find Inkless commits inside a sync merge. The 4.1 session log first listed the hashes of the release-branch cherry-picks. The session template and the guide's agent prompt now ask for the hashes of the commits on main, as the other logs list them. The session logs record the cherry-pick of #882 through #927 to `inkless-4.1`, `inkless-4.2`, and `inkless-4.3`, and of #911 through #927 to `inkless-4.4`, with the follow-up pick of `ca375e2131` and the 4.3 jOOQ fix. Assisted-by: Claude Opus 5.5
viktorsomogyi
pushed a commit
that referenced
this pull request
Dec 4, 2026
…branch (#939) 0.53 is the first release of `inkless-4.4`, so the branch joins the active table in `RELEASES.md`. The cherry-pick guide now places main at the 4.4 branch point and records the adaptations of this round: the SpotBugs exclude on 4.3, and the `forwarded` argument and the reassignment completion rule on 4.2 and 4.1. `ca375e2131` reached `main` inside the upstream sync merge #897, so `branch-consistency.sh` didn't list it, and the 4.1, 4.2, and 4.3 release-prep PRs failed `Compile and Check Java` without it. The guide now shows how to find Inkless commits inside a sync merge. The 4.1 session log first listed the hashes of the release-branch cherry-picks. The session template and the guide's agent prompt now ask for the hashes of the commits on main, as the other logs list them. The session logs record the cherry-pick of #882 through #927 to `inkless-4.1`, `inkless-4.2`, and `inkless-4.3`, and of #911 through #927 to `inkless-4.4`, with the follow-up pick of `ca375e2131` and the 4.3 jOOQ fix. Assisted-by: Claude Opus 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