feat(inkless:switch): detect classic-prefix upload and request the tiered flag [KC-588] #835
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
giuseppelillo
In the two-phase classic-to-diskless switch, phase 2 starts when the controller sets
classicPrefixInRemoteStorage. The controller already handlesSetClassicPrefixInRemoteStorage, 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 theWaitingForUploadandSendingFlagToControllerstates.AwaitingMetadata.onSuccessreturnsWaitingForUploadwhen the flag is unset andDonewhen 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 whenlogStartOffset >= seal || highestOffsetInRemoteStorage >= seal - 1. The first term covers a prefix that retention orDeleteRecordsalready removed, where the remote gauge stays at-1.SendingFlagToControllerBatchQueue: batchSetClassicPrefixInRemoteStoragerequests and send them only while the broker leads the partition. The queue treatsINVALID_REQUEST,UNKNOWN_TOPIC_ID, andUNKNOWN_TOPIC_OR_PARTITIONas permanent failures and retries every other error. It reads the leader epoch when it builds each request. This differs fromInitDisklessLog. 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: passclassicPrefixInRemoteStoragetoinitOnControlPlane, 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 returnsalready_initializedfor the repeated call. InInitDisklessLogManager, 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.WaitingForUploadPartitions,SendingFlagToControllerPartitions,OldestWaitingForUploadAgeMs, andOldestSendingFlagToControllerAgeMs.InFlightPartitionsstill counts only the three init states, so system tests that wait for it to reach 0 don't block on a long upload. Add theFlagRequestCompletedPerSec,FlagRequestFailedPerSec, andFlagRequestRetriedPerSecmeters. They're separate from theInit*PerSecmeters, so a stuck flag request doesn't look like a failing init.FlagRequestFailedPerSeccounts only controller rejections, not a request skipped after a leadership change or a topic deletion.DisklessSwitchedPartitionsPendingUploadCount, which counts partitions of diskless topics that have a committed seal and no flag.CLASSIC_TO_DISKLESS_SWITCH.md, and add the controller metric toFEATURES.md.The PR has four commits:
Test plan
InitDisklessLogManagerTestcovers 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.DisklessSwitchFlowTestcovers the flow from a metadata delta to the flag request.ReplicaManagerInklessTestchecks that a new leader passes the registration's flag toinitOnControlPlane, 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.ControllerMetadataMetricsTestandControllerMetadataMetricsPublisherTestcover snapshot loading, seal commits, flag commits, topics created through a delta, diskless config changes, classic topics, and topic deletion.make valepasses.Known limitations
Assisted-by: Claude Sonnet 5.5
Assisted-by: Claude Opus 5.5