← Back to Pull requests

fix(inkless:consolidation): don't supplement an empty local read of a consolidating partition [KC-848] #907

Closed
unknown closed this pull request without merging on Nov 27, 2026 12:50 UTC
View on GitHub
unknown unknown commented on Nov 27, 2026 09:58 UTC
Author

Summary

A lagging consumer of a consolidating partition can skip committed records without an error. The broker may answer a fetch inside the local log with records that start at the local log end offset instead of the fetch offset. This happens when the local read comes back empty with no error. An earlier partition in the request can use up the byte budget and cause that read. buildConsolidationSupplementFetchInfos anchored the diskless supplement for that read at the log end offset, so the exhaustion guard passed. The consumer then moved past fetchOffset, logEndOffset).

buildConsolidationSupplementFetchInfos now anchors an empty read at the fetch offset. The guard then drops the supplement, and the consumer fetches again from its own offset. It also skips a partition whose local read returns a preferred read replica or a remote storage redirect. Both fetch paths call the helper. The change also covers DelayedFetch.onComplete, which has none of the inline path's guards.

 buildConsolidationSupplementFetchInfos(partition)
-  skip if the local read has an error
+  skip if the local read has an error, a preferred read replica, or a remote storage redirect
   start = nextOffset of the last local batch
-          or logEndOffset if the read is empty
+          or fetchOffset if the read is empty
   supplement only if start >= logEndOffset and bytes remain

Follow-ups, not in this change:

  • KC-876: the broker merges a local read that ends partway through a batch in front of the supplement, and the consumer gets a CRC failure.

  • DelayedFetch.onComplete issues the supplement without checking minBytes again. DISKLESS_CONSOLIDATION.md now states this behavior.

  • fetchParamsWithNewMaxBytes gives every leg of a mixed fetch the full byte budget.
  • Evidence

  • Before: a mixed request through DelayedFetch.onComplete requests a supplement for both consolidating partitions. The second partition's local read is empty, and its response starts at the log end offset.

  • After: only the first partition gets a supplement. The second partition's response is empty, and the consumer fetches again from its offset.

    testEmptyLocalReadOfSecondConsolidatingPartitionGetsNoSupplement
      P0 local read reaches the log end offset
      P1 local read at offset 400 returns no records, log end offset 1000
      assert the supplement covers P0 only
      assert the P1 response holds no records past offset 400
    

  • Without the change to ReplicaManager, the three new DelayedFetchTest tests and four new buildConsolidationSupplementFetchInfos tests fail.

  • testBuildConsolidationSupplementFetchInfosSkipsEmptyLocalReadBelowLogEndOffset replaces the test that pinned the old behavior. It asserts that the helper doesn't emit a supplement. testCompletionWithConsolidationSupplement uses a local read that reaches the log end offset, so it still covers the merge.

  • DelayedFetchTest and ReplicaManagerInklessTest pass with 338 tests. ReplicaManagerTest passes with 129 tests. :core:checkstyleTest passes, and make vale doesn't report alerts on the added lines.
  • Merge danger

    Door: two-way

    The change touches only the broker fetch path. It doesn't write state or change a protocol or config. A revert restores the previous behavior.

    Blast radius: consolidating partitions

    Only consumer fetches of consolidating partitions that start inside the local log change. After an empty local read, the response for that partition used to contain a supplement. It's now empty. The consumer fetches again, so a lagging consumer can take more round trips to catch up. Classic partitions, pure diskless partitions, and follower fetches don't change.

    🤖 Generated with [Claude Code

    Assisted-by: Claude Sonnet 5.5
    Assisted-by: Claude Opus 5.5

    Diff: 480 lines (+360 / -120) across 6 files Reviewer: giuseppelillo Review duration: 172m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.47) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.47 · 480 lines diff across 6 files
    0.47
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.369
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #907"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.3% (MEDIUM) · Higher = larger blast radius
    47.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.7% · Safe to merge
    18.7%
    Repository