8000 fix(inkless:consolidation): skip the diskless supplement when the local read ends mid-batch [KC-876] by viktorsomogyi · Pull Request #911 · aiven/inkless · GitHub
[go: up one dir, main page]

Skip to content

fix(inkless:consolidation): skip the diskless supplement when the local read ends mid-batch [KC-876] - #911

Merged
jeqo merged 3 commits into
mainfrom
svv/kc-876-partial-batch
Dec 2, 2026
Merged

jeqo merged 3 commits into
mainfrom
svv/kc-876-partial-batch

Conversation

@viktorsomogyi
Copy link
Copy Markdown
Contributor

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 DelayedFetch captures 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

buildConsolidationSupplementFetchInfos skips 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.onComplete uses. That idea from the ticket is a separate change.

Test plan

  • Add testBuildConsolidationSupplementFetchInfosSkipsWhenLocalReadEndsMidBatch to ReplicaManagerInklessTest. The test fails without the guard and passes with it.
  • Run ReplicaManagerInklessTest (321 tests) and DelayedFetchTest (5 tests) with no failures.
  • Run make vale with no alerts.

Fixes KC-876.

🤖 Generated with Claude Code

…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
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are identified for the change that suppresses diskless supplements after truncated local reads.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@viktorsomogyi
viktorsomogyi requested a review from jeqo November 30, 2026 08:55
@jeqo jeqo left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@viktorsomogyi
viktorsomogyi requested a review from jeqo December 1, 2026 15:43
@jeqo
jeqo merged commit 3115387 into main Dec 2, 2026
6 checks passed
@jeqo
jeqo deleted the svv/kc-876-partial-batch branch December 2, 2026 08:14
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

0