feat(inkless:controller): gate ISR, reassignment, and leader election on switch phase #833
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 #833"
general
weight: 0.35
giuseppelillo
In the two-phase classic-to-diskless switch, phase 1 lasts while a partition has a seal (
classicToDisklessStartOffset != -1) andclassicPrefixInRemoteStorageisfalse. During phase 1, the classic prefix below the seal exists only on the replicas' local disks, so the controller must enforce classic ISR, reassignment, and leader election rules. OnceclassicPrefixInRemoteStorageistrue(phase 2), the prefix lives in remote storage and no replica relies on its local copy, so the controller applies born-diskless rules.This PR adds
isSwitchedWithLocalClassicPrefix(PartitionRegistration)onReplicationControlManagerand gates the controller's switch-sensitive paths on it. Broker-side ISR shrink for lag in phase 1 moves to a follow-up PR, as it requires consolidation stop in phase 1 which is not implemented yet.Changes
ReplicationControlManager.isSwitchedWithLocalClassicPrefix: returnstruewhenclassicToDisklessStartOffset != NO_CLASSIC_TO_DISKLESS_START_OFFSETandclassicPrefixInRemoteStorageisfalse.ReplicationControlManager.alterDisklessSwitch: reject any seal modification onceclassicPrefixInRemoteStorageistrue, including lowering the seal. In phase 2, brokers delete their local prefix below the committed seal and start consolidating from it, so the seal can't move afterward.ReplicationControlManager.leaderAcceptorFor(both overloads): useLeaderAcceptor(which requires an online replica directory) whenisSwitchedWithLocalClassicPrefix(partition)istrue, and keepisActive-only for born-diskless and phase-2 partitions.ReplicationControlManager.changePartitionReassignment: take the stagedaddingReplicas/removingReplicaspath whenisSwitchedWithLocalClassicPrefix(part)istrue, and take the one-step path for born-diskless and phase-2 partitions. This supersedes #757. When an administrator retargets a diskless partition that already has a reassignment in progress, the staged path reconciles the inherited adding and removing replicas against the new target, and the one-step path clears them even when the new target equals the current replicas.ReplicationControlManager.expandIsrForDisklessManagedPartitions: skip unfence ISR expansion only whileisSwitchedWithLocalClassicPrefix(partition)istrue, so phase-2 partitions re-add unfenced replicas and complete in-flight reassignments like born-diskless partitions. Passr -> r == brokerId || clusterControl.isActive(r)toleaderAcceptorForso an in-flight reassignment that removes the current leader can elect the unfencing broker before itsBrokerRegistrationChangeRecordis replayed.Test plan
ReplicationControlManagerInklessTest.testAlterDisklessSwitchRejectedAfterClassicPrefixInRemoteStorage: verifies that lowering (0,50), matching (100), raising (150), and negative (-1,-2) seal offsets all fail withInvalidRequestExceptiononce the flag is set.ReplicationControlManagerInklessTest$DisklessManagedReplicasTests.testLeaderElectionRequiresOnlineDirectoryUntilClassicPrefixIsInRemoteStorage: verifies that a replica withDirectoryId.LOSTcan't win leader election in phase 1 or while the switch is pending (via bothhandleBrokerFencedandelectLeader), and can win in phase 2.ReplicationControlManagerInklessTest$DisklessManagedReplicasTests: covers staged reassignment completion and cancellation in phase 1 (testReassignSwitchedPartitionStagesTargetInsteadOfGrantingIsr,testCancelReassignmentOfSwitchedPartitionRevertsStagedState,testReassignConsolidatingSwitchedPartitionAlsoStages) and one-step reassignment in phase 2 (testReassignSwitchedPartitionWithClassicPrefixInRemoteStorageCompletesInOneStep).ReplicationControlManagerInklessTest$DisklessManagedReplicasTests.testUnfenceExpandsIsrOfBornDisklessButNotSwitchedPartitions: verifies that unfencing expands ISR for born-diskless and phase-2 partitions and skips phase-1 and pending-switch partitions.ReplicationControlManagerInklessTest$SetClassicPrefixInRemoteStorageTests.testSetClassicPrefixInRemoteStorageInFlightReassignmentCompletesOnLaterPhase2Unfence: verifies that a staged reassignment still in flight when the flag commits completes when the adding replica unfences in phase 2.Known limitation
A consolidating follower can leave the classic fetcher at the seal without reporting itself in sync. Until a follow-up PR stops consolidation in phase 1, a phase-1 reassignment that adds such a follower can wait for the flag commit to finish it. The controller side in this PR handles that case: the flag commit completes the reassignment and elects the leader with phase-2 rules.
ReplicationControlManagerInklessTest$DisklessManagedReplicasTests.testRetargetAfterFlagKeepsRequestedReplicasWhenTargetKeepsRemovingReplicaandtestRetargetAfterFlagClearsStaleAddingReplica: verify that retargeting a partition whose phase-1 reassignment survived the flag commit uses exactly the requested replicas.ReplicationControlManagerInklessTest$SetClassicPrefixInRemoteStorageTests.testSetClassicPrefixInRemoteStorageElectsLeaderWithLostDirectoryWhenCompletingReassignment: verifies that the flag commit elects a leader among the target replicas when they all have lost directories.ReplicationControlManagerInklessTest$DisklessManagedReplicasTests.testRetargetAfterFlagToExactCurrentReplicasClearsUnfinishedReassignment: verifies that requesting exactly the current replicas clears an unfinished phase-1 move after the flag commits.ReplicationControlManagerInklessTest$DisklessManagedReplicasTests.testRetargetStagedReassignmentDropsAddingReplicaThatIsNoLongerRequestedandtestRetargetStagedReassignmentKeepsCatchUpForAddingReplicaStillRequested: verify that retargeting a staged phase-1 reassignment drops adding replicas that are no longer requested and keeps catch-up for the ones that still are.Assisted-by: Gemini 4 Argon