← Back to Pull requests

feat(inkless:switch): detect classic-prefix upload and request the tiered flag [KC-588] #835

Closed
unknown closed this pull request without merging on Oct 29, 2026 14:43 UTC
View on GitHub
unknown unknown commented on Oct 22, 2026 08:37 UTC
Author

In the two-phase classic-to-diskless switch, phase 2 starts when the controller sets classicPrefixInRemoteStorage. The controller already handles SetClassicPrefixInRemoteStorage, but no broker sends it. A switched partition never leaves phase 1. The leader is the only broker that can tell when the classic prefix [0, seal) is in remote storage, so it requests the flag.

This PR stacks on #833. Merge #833 first, then retarget this PR to main. KC-589 adds the broker behavior that depends on the flag.

Changes

  • InitDisklessLogState: add the WaitingForUpload and SendingFlagToController states. AwaitingMetadata.onSuccess returns WaitingForUpload when the flag is unset and Done when the registration has the flag.

  • InitDisklessLogManager: poll tracked partitions once per second with a self-rescheduling one-shot task that stops when no partition waits. A partition counts as uploaded when logStartOffset >= seal || highestOffsetInRemoteStorage >= seal - 1. The first term covers a prefix that retention or DeleteRecords already removed, where the remote gauge stays at -1.

  • SendingFlagToControllerBatchQueue: batch SetClassicPrefixInRemoteStorage requests and send them only while the broker leads the partition. The queue treats INVALID_REQUEST, UNKNOWN_TOPIC_ID, and UNKNOWN_TOPIC_OR_PARTITION as permanent failures and retries every other error. It reads the leader epoch when it builds each request. This differs from InitDisklessLog. An epoch bump that keeps the same leader fences the in-flight request but doesn't register the watch again, so the retry has to send the current epoch.

  • ReplicaManager: pass classicPrefixInRemoteStorage to initOnControlPlane, and call it whenever the committed seal changes, not only on its first commit. An operator re-seal in phase 1 keeps the leader and the leader epoch. Without this trigger, the watch keeps the old seal: it either waits for an upload past the new seal or sends a request that the controller rejects. The control-plane init returns already_initialized for the repeated call. In InitDisklessLogManager, a re-init replaces the tracked state in one map write. A control-plane init completion advances only the state that queued it, and a flag response removes only the state that queued it. A response for the old seal can't drop the new watch or move it past its own init.

  • ReplicaManager: when a switched leader in phase 1 applies a delta, roll its active segment if the log reaches the seal and the segment starts below it. The remote log manager copies closed segments only. A promoted follower can keep the prefix tail in its active segment, and consolidation appends diskless records to that same segment. Without the roll, the tail becomes uploadable only when the segment rolls on size or age, which never happens on an idle topic. A consolidating leader whose log ends before the seal rebuilds the prefix from remote storage and doesn't hold the tail, so it isn't rolled.

  • Broker metrics: add WaitingForUploadPartitions, SendingFlagToControllerPartitions, OldestWaitingForUploadAgeMs, and OldestSendingFlagToControllerAgeMs. InFlightPartitions still counts only the three init states, so system tests that wait for it to reach 0 don't block on a long upload. Add the FlagRequestCompletedPerSec, FlagRequestFailedPerSec, and FlagRequestRetriedPerSec meters. They're separate from the Init*PerSec meters, so a stuck flag request doesn't look like a failing init. FlagRequestFailedPerSec counts only controller rejections, not a request skipped after a leadership change or a topic deletion.

  • Controller metric: add DisklessSwitchedPartitionsPendingUploadCount, which counts partitions of diskless topics that have a committed seal and no flag.

  • Docs: describe the new step and the re-seal handling in CLASSIC_TO_DISKLESS_SWITCH.md, and add the controller metric to FEATURES.md.
  • The PR has four commits:

  • The controller metric.

  • The detection and flag request on the broker, including the re-seal trigger and the broker metrics.

  • The roll on a promoted leader.

  • The docs.
  • Test plan

  • InitDisklessLogManagerTest covers the detection rule, the empty prefix, and the upload poller. It also covers request contents and batching, each response disposition, retries with a refreshed leader epoch, re-init while a request waits in the queue, re-init with a lower seal, a stale control-plane init that completes during a re-init, leader change, partition removal, the new gauges, and the flag request meters.

  • DisklessSwitchFlowTest covers the flow from a metadata delta to the flag request.

  • ReplicaManagerInklessTest checks that a new leader passes the registration's flag to initOnControlPlane, and that an operator re-seal on the same leader calls it again with the lower seal. It also checks that the leader rolls a promoted follower's tail and a consolidating leader's active segment that mixes classic and diskless records. The leader skips the roll in phase 2, with an empty or diskless-only active segment, and for a consolidating leader whose log ends before the seal.

  • ControllerMetadataMetricsTest and ControllerMetadataMetricsPublisherTest cover snapshot loading, seal commits, flag commits, topics created through a delta, diskless config changes, classic topics, and topic deletion.

  • make vale passes.
  • Known limitations

  • A broker that runs this change sets the flag after the upload finishes. A configuration option doesn't gate this. Brokers don't change behavior on the flag until KC-589.
  • Assisted-by: Claude Sonnet 5.5
    Assisted-by: Claude Opus 5.5

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: giuseppelillo Review duration: 10446m
    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 #835"
    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