← Back to Pull requests

fix(inkless:switch): defer timestamp ListOffsets below the diskless log start [KC-761] #870

Closed
unknown closed this pull request without merging on Nov 13, 2026 12:25 UTC
View on GitHub
unknown unknown commented on Nov 12, 2026 12:34 UTC
Author

A timestamp ListOffsets lookup can return an offset past records that the partition still stores. The consumer then skips those records without an error.

On a hybrid partition, the broker searches its local log first and asks the control plane only if nothing matches. The control plane searches from the first retained WAL batch. If the local log ends before that batch, neither search reads the offsets in between.

The following replicas hit this:

  • A switched leader below the seal. The KC-702 divergent-tail check recreates it empty, or it lost its disk, and the broker keeps it online so that consolidation can rebuild it.

  • A consolidating replica that the WAL prune passed, such as a reassignment target, a replica that lost its data, or a follower that lags the prune. Any replica of a consolidating topic answers ListOffsets, and the pruner doesn't wait for replicas.
  • Example

    A born-diskless consolidating topic holds offsets 0 to 1199, with timestamps 10000 + offset. The leader has tiered up to 799, and the prune moved the WAL start to 800. Replica B is a reassignment target with an empty log. A consumer in the zone of B calls offsetsForTimes(10100):

    | Replica | What happens | Consumer gets |
    | --- | --- | --- |
    | Leader | The local search finds offset 100. | 100 |
    | B, before this change | The local search finds nothing. The control plane returns its oldest batch, 800, because its timestamp 10800 is at or past 10100. | 800, and skips 100 to 799 |
    | B, after this change | The local log ends before the WAL start. | OFFSET_NOT_AVAILABLE, and the consumer retries |

    Changes

    The router returns the retriable OFFSET_NOT_AVAILABLE (LEADER_NOT_AVAILABLE before version 5) when the local log ends before the diskless log. The Fetch path already does this for the same window. A match in the local log is still returned.

  • Switched replica below the seal: the lookup fails without a control-plane call.

  • Consolidating partition outside phase 1 of the switch: FetchOffsetHandler.Job.addWalStart reads the WAL start in the same control-plane call as the timestamp lookup. The lookup fails if the local log ends before the WAL start, or before the seal if that's later. Job now matches responses to requests by position, because a partition can appear twice. A response for another partition fails the lookups.

  • Searchable end of the local log: this is the log end offset. While the leader epoch cache can't resolve the log start, the searchable end is the log start. A tier-state rebuild truncates the log before it restores that cache, and until then the remote search finds nothing.

  • Search range snapshot: the broker reads the truncation count and the log start before the searchable end. When the lookup decides, the range counts only if the log is the same instance with the same truncation count and log start. A rebuild, truncation, recreation, or log start move during the lookup fails the lookup.

  • ConsolidationDeferredListOffsetsRate: a new ReplicaManager meter counts the deferred lookups. Errors from the control plane don't count. DISKLESS_CONSOLIDATION.md lists it.

  • LeaderEpochFileCache.assign(List): it validates the entries before it changes the cache, and it holds the write lock across them. A reader sees none of the restored epochs or all of them. INKLESS_OWNERSHIP lists the file as interleaved.
  • The WAL start check applies only while the broker consolidates the partition. A switched partition that doesn't consolidate, or one in phase 1, keeps its log at the seal. There, diskless retention or a DeleteRecords past the seal would fail every local miss.

    Trade-off

    A consolidating replica that can't rebuild answers timestamp lookups with OFFSET_NOT_AVAILABLE until it rebuilds. This happens when the remote prefix is unknown or when the consolidation fetcher parks the partition. Before this change, the replica returned a wrong offset. ConsolidationDeferredListOffsetsRate shows a replica in this state.

    Testing

  • DisklessFetchOffsetRouterTest covers a switched replica below the seal, with sync and async local lookups, the version mapping, and a local match. It also covers a consolidating replica before and past the WAL start, a diskless lookup that doesn't match, a search range that stops being current, the seal bound before the first prune, forwarded errors, and the fresh-job fallback.

  • FetchOffsetHandlerTest covers request order, positional matching, the cross-tier earliest cache, failures, and a response-count mismatch.

  • ReplicaManagerInklessTest checks that the KC-702 recreated leader and an empty consolidating replica get OFFSET_NOT_AVAILABLE, and that a caught-up replica gets the diskless offset. It also covers the rebuild window with no epoch for the log start, a rebuild during the lookup, and a log start that moves during the lookup. The existing fallback tests that stub the local lookup now create a local log at the seal.

  • DisklessFetchOffsetRouterTest and ReplicaManagerInklessTest check that each deferred lookup marks ConsolidationDeferredListOffsetsRate once, and that other answers don't.

  • LeaderEpochFileCacheTest checks that a reader sees none or all of a restored list of epoch entries.

  • With each guard turned off, the tests that expect the error fail.

  • InklessDisklessListOffsetsTest passes against Postgres, and RemoteLogManagerTest, UnifiedLogTest, and TierStateMachineTest pass.
  • KC-761

    🤖 Generated with Claude Code

    Assisted-by: Claude Opus 5.5

    [KC-761]: https://aiven.atlassian.net/browse/KC-761?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: giuseppelillo Review duration: 1430m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    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.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #870"
    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: 52% (MEDIUM) · Higher = larger blast radius
    52%
    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: 20.5% · Safe to merge
    20.5%
    Repository