feat(inkless:switch): elect a chosen replica in phase 1 of the classic-to-diskless switch [KC-717] #882
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 #882"
general
weight: 0.35
giuseppelillo
In phase 1 of the classic-to-diskless switch, only the replicas' local disks store the classic prefix, and the controller blocks unclean leader election. If the only ISR member loses its disk, the partition goes offline and no command brings it back:
ReplicaManager.applyLocalLeadersDeltadoesn't create the partition. No broker serves it.rearmre-sets the current leader andlower-sealkeeps it, so neither command moves leadership to a replica that still has the classic prefix. This PR adds a command that does.Add the
electsubcommandkafka-topic-switch.sh elect --topic <topic> --partition <partition> --replica <broker-id>elects the chosen replica as the leader of a partition in phase 1, even if the replica is outside the ISR. The command accepts--bootstrap-serveror--bootstrap-controller.The command sends
AlterDisklessSwitchwith a newLeaderIdfield and a seal offset of-1, which keeps the seal. The field joins version 0 of the request. The switch isn't used in production yet, so the request doesn't need a new version.AlterDisklessSwitchOptions.leaderId(int)sets the field, so theAdmininterface keeps its methods.On the controller,
ReplicationControlManager.electPhaseOneLeaderrunsPartitionChangeBuilderwith an unclean election and a leader predicate that accepts only the chosen replica:RECOVERING.The controller rejects the request with
INVALID_REQUESTin these cases:PartitionChangeBuildercompletes a reassignment whose adding replicas are all in the ISR before it elects a leader, and it then drops the removing replicas.-1, or a leader ID below-1.The phase 1 guards on unclean leader election don't change.
ElectLeaderswith typeUNCLEAN, the config check, and the automatic election paths still reject or skip the election.The broker code doesn't change. A leader whose log ends at a committed seal serves the partition. A leader whose log ends below it marks the partition offline, and
lower-sealthen applies as it does after a last-known-leader election. A leader without a log for the partition doesn't create it, and the operator elects another replica.CLASSIC_TO_DISKLESS_SWITCH.mdhas a new section, "Elect a chosen replica in phase 1", with the command, the rejections, the outcomes on the broker, and the limitations.Limitations
Test plan
./gradlew :clients:checkstyleMain :metadata:checkstyleMain :metadata:checkstyleTest :tools:checkstyleMain :tools:checkstyleTest :core:checkstyleTest :core:spotlessJavaCheck :metadata:spotlessJavaCheckpasses, andmake valereports no alerts.ReplicationControlManagerInklessTest,TopicSwitchCommandTest,RequestResponseTest,MessageTest, andInklessTopicTypeSwitcherClusterTest.ReplicationControlManagerInklessTestelects a replica outside the ISR with a committed seal, with and without a live leader, and with a pending switch. It checks the leader, the ISR, theRECOVERINGstate, the leader epoch bump, and that the seal stays. It also elects an ISR member and checks that the ISR stays.TopicSwitchCommandTestchecks thatelectsends the replica with a seal offset of-1, rejects a negative replica before it calls the controller, accepts--bootstrap-controller, and requires--partitionand--replica.InklessTopicTypeSwitcherClusterTest.testElectedReplicaOutsideTheIsrRecoversAPhaseOnePartitionswitches a topic with two replicas and a committed seal. It shuts down the follower, then the leader, and restarts the follower. The partition has no leader. Afterelect, the follower leads with an ISR of one, a consumer reads the whole classic prefix, the partition takes diskless records, and the old leader rejoins the ISR after its restart. The test then creates the bucket of the tiered storage plugin, and the partition enters phase 2.blocks-remote-uploads, for which the setup configures the tiered storage plugin with a bucket that doesn't exist. Segment uploads fail until the test creates the bucket, which it does after the recovery. The test asserts thatclassicPrefixInRemoteStorageis unset before the election. In a local run with a temporary 15-second wait before that assertion, the test fails with the default bucket and passes with the missing one.:core:testto its two forks in turn, by class file. An earlier version of this test added a nested class, which moved both 256-second cluster test classes to the same fork.:core:testthen took 17 minutes instead of 11 in CI, and the test step reached its 30-minute limit.checkstyle/suppressions.xmlexemptsInklessTopicTypeSwitcherClusterTestfromClassFanOutComplexity. The new test takes the class over the limit of 55.🤖 Generated with Claude Code