← Back to Pull requests

fix(inkless:switch): serve pending ListOffsets from the classic log and defer lookups past a stale high watermark [KC-756] [KC-763] #873

Closed
unknown closed this pull request without merging on Nov 16, 2026 17:51 UTC
View on GitHub
unknown unknown commented on Nov 16, 2026 15:52 UTC
Author

This PR fixes two cases where DisklessFetchOffsetRouter asks the control plane for offsets that the control plane can't answer correctly.

Pending switch on a consolidating topic

A partition whose switch is pending (classicToDisklessStartOffset = -2) took the classic-only path only if the topic didn't consolidate. The switch sets remote.storage.enable, and the topic reads as consolidating from that point. The pending partition then took the hybrid path:

  • EARLIEST_TIMESTAMP, LATEST_TIMESTAMP, and MAX_TIMESTAMP went to the control plane.

  • The control plane has no entry for the partition until the seal commits, and answers UNKNOWN_TOPIC_OR_PARTITION.

  • DelayedRemoteListOffsets maps that exception to the client response.
  • kafka-topic-switch.sh state calls listOffsets for the earliest and latest offsets of every partition, and failed on a pending partition.

    A pending partition now takes the classic-only path on every topic. For example, with a classic log that holds offsets 0 to 999, LATEST returns 1000 and EARLIEST returns 0 while the switch is pending.

    The leader and the in-sync followers answer client requests. InklessTopicMetadataTransformer advertises any alive ISR member as the leader while the classic prefix lives only on local disks, which includes the pending state. A leader-only lookup would answer NOT_LEADER_OR_FOLLOWER to a client that the transformer sent to a follower. A replica outside the ISR, and every replica fetcher request, still gets the leader-only lookup. This rule also applies to a pending partition of a topic that doesn't consolidate, which was leader-only before.

    Stale high watermark on a hybrid partition

    For a timestamp lookup, the router searches the local log first and asks the control plane on a miss. A client lookup hides a match at or past the last fetchable offset: classicFetchOffset answers NONE with offset -1. The router read that answer as a miss.

    For example, a consolidating replica restarts with high watermark 1100 and log end offset 1300, and the WAL is pruned up to 1200. A consumer asks for a timestamp whose first match is offset 1150. The local search hides the match, the control plane searches from 1200 and returns 1200, and the consumer skips offsets 1150 to 1199 without an error.

    The guard from #870 compares the searchable end of the local log with the start of the diskless log. It used the log end offset (1300), which is past the diskless start (1200). For a client request, classicSearchRange now ends at the high watermark, or at the last stable offset for read_committed. In the example, 1100 is before 1200, and the lookup gets OFFSET_NOT_AVAILABLE (LEADER_NOT_AVAILABLE before version 5) until the high watermark moves past the WAL start. A replica request keeps the log end offset.

    The same bound covers a switched leader whose high watermark is below the seal: the existing seal check defers the lookup.

    Not in this PR

    After the controller commits the seal and until the leader initializes the control plane, ListOffsets for the latest offset still fails with UNKNOWN_TOPIC_OR_PARTITION. On a consolidating topic, the earliest offset fails the same way. This PR doesn't fall back to the classic log there. PostgresControlPlane runs ListOffsets on the read connection, and a read replica that lags behind the primary reports a missing entry for a partition that already holds diskless records. A fallback would then return a stale offset instead of an error.

    No system test runs kafka-topic-switch.sh state on a pending partition.

    Testing

  • DisklessFetchOffsetRouterTest covers a pending partition of a consolidating topic for the latest, earliest, max, and specific timestamps. It also covers a client request on an in-sync replica and a replica fetcher request on an in-sync replica.

  • ReplicaManagerInklessTest covers a pending partition of a consolidating topic on a real local log: the latest and earliest offsets on an in-sync follower, and NOT_LEADER_OR_FOLLOWER outside the ISR. The control plane gets no call.

  • ReplicaManagerInklessTest covers a timestamp lookup on a replica with high watermark 700, log end offset 900, and WAL start 800. A client lookup gets OFFSET_NOT_AVAILABLE for a hidden match and for a miss. A client lookup with high watermark 850 and a replica lookup get the control-plane offset.

  • With the high watermark bound turned off, the two cases that expect OFFSET_NOT_AVAILABLE fail.

  • DisklessFetchOffsetRouterTest and ReplicaManagerInklessTest pass.
  • 🤖 Generated with Claude Code

    Assisted-by: Claude Fable 5.2

    Diff: 587 lines (+440 / -147) across 7 files Reviewer: viktorsomogyi Review duration: 119m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 587 lines diff across 7 files
    0.50
    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.382
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #873"
    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: 49.9% (MEDIUM) · Higher = larger blast radius
    49.9%
    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: 19.7% · Safe to merge
    19.7%
    Repository