refactor(inkless:switch): replace the seal and repair commands with rearm and lower-seal #872
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 #872"
general
weight: 0.35
giuseppelillo
This PR reduces
kafka-topic-switch.shto a read-onlystatecommand and two narrow write commands,rearmandlower-seal. It removes every other operator command that writes a seal offset or changes the control plane.Removed:
sealcommand, with all its options:--offsetwithN ≥ 0,-1, and-2, plus--clear-producer-statesand--dry-run.repaircommand.AlterDisklessSwitchinput except two:-2on a pending switch, and a seal lower than the committed seal in phase 1. TheClearProducerStatesfield is gone, andAlterDisklessSwitchOptionsno longer hasclearProducerStates.RepairDisklessLogbroker RPC, along withAdmin.repairDisklessLog, its broker handler, its control plane code in both implementations, and its metrics.repair_diskless_log_v1Postgres function and its types, which migrationV32__Remove_repair_diskless_log.sqldrops.New:
rearm --topic T --partition Pcommand. It sendsAlterDisklessSwitchwith-2, which the controller accepts only while the switch is pending. The controller bumps the leader epoch, so the leader seals again.lower-seal --topic T --partition P --offset Ncommand. It sendsAlterDisklessSwitchwithN, which the controller accepts only for a committed seal in phase 1 and a seal that is at least 0 and lower than the committed one. The command rejects a negative offset before it sends the request, because the controller reads-2as a re-arm. It keeps the recovery in the "Last-known-leader election" section ofCLASSIC_TO_DISKLESS_SWITCH.mdworking: after a last-known-leader election picks a leader whose log ends below the seal, lowering the seal to that leader's log end offset brings the partition back.Unchanged:
statecommand.Before and after
Each row of the following table describes a problem an operator can face, how the tooling handled it before this PR, and how it's handled after. The last column describes what to do in the cases this PR makes impossible.
| Problem | Before this PR | After this PR | How to deal with it |
| --- | --- | --- | --- |
| A pending switch doesn't progress because the leader isn't driving it, for example after the leader restarted while the switch was pending. |
seal --offset -2re-arms the switch. The controller bumps the leader epoch, so the leader seals again and registers the partition forInitDisklessLog. |rearm --topic T --partition Pdoes the same thing. It sendsAlterDisklessSwitchwith-2. | Not needed || A pending switch is stuck because the ISR dropped below
min.insync.replicas, so the high watermark can't reach the sealed log end offset. |seal, with or without--offset N, commits a seal without the leader. The seal carries no producer states, so an idempotent producer that was active before the seal fails withOUT_OF_ORDER_SEQUENCE_NUMBERon its next batch. If the seal is above the high watermark, it includes records that aren't fully replicated. | Restart the brokers of the out-of-sync followers. They keep fetching up to the sealed log end offset while the switch is pending, and once they rejoin the ISR, the leader proposes the seal. If they can't come back, lower the topic'smin.insync.replicasand runrearm: the leader recomputes its high watermark and proposes the seal with producer states. Adding new replicas doesn't help, because a new replica doesn't fetch until the seal commits. | Not needed || A phase 1 partition is offline because a last-known-leader election picked a leader whose log ends below the seal. No other replica can lead, and phase 2 can't start. |
seal --offset Nlowers the seal to the leader's log end offset. The same command also accepts a pending switch,-1, and-2. The documented procedure then runsrepair, which writes a control plane column that nothing reads. |lower-seal --offset NsendsAlterDisklessSwitchwithN. The controller accepts it only for a committed seal in phase 1 and a seal lower than the committed one. The procedure has norepairstep. In both cases, every replica truncates its classic log toN, the control plane keeps the diskless log starting at the old seal, and the partition loses the records betweenNand the old seal. A consumer that reads across them gets the diskless records from the old seal on, without an error. | Not needed || The committed producer states should be cleared. |
seal --clear-producer-statesnever works. The controller builds a record with tags out of order, which can't be serialized. Each attempt makes the active controller resign, and the client getsUNKNOWN_SERVER_ERROR. | Not possible. | Not needed. The option only applied to a forced seal (--offset NwithN ≥ 0), whose seal could disagree with the producer states already committed. The leader commits the seal and the producer states together, from the same log end offset, so they always match. || A pending switch should be canceled, and the partition should go back to classic. |
seal --offset -1doesn't revert the partition. The topic keepsdiskless.enable=true, so produce takes the diskless path and fails withUNKNOWN_TOPIC_OR_PARTITION, the classic log stays sealed, and the controller guards for a local-only classic prefix stop applying. Nothing can undo it: the controller rejects any laterAlterDisklessSwitchfor the partition, settingdiskless.enable=trueagain starts no switch, anddiskless.enablecan't be disabled. | Not possible. A switch can only be finished, withrearmor a leader election. | The switch must be completed. || The control plane disagrees with the seal in KRaft after an operator lowered the seal. |
repairsets the control plane'sdiskless_start_offsetto the new seal. Nothing at runtime reads that column, so it changes nothing for produce, fetch, orListOffsets. | No command reconciles them, and nothing needs it. The control plane keeps the diskless log starting at the old seal. A consumer reads the classic records up to the new seal, then the diskless records from the old seal on. See the preceding note. | Not needed |Test plan
./gradlew check -x test -x generateJooqClassesandmake docspass, with no uncommitted changes.make valereports no alerts.TopicSwitchCommandTest,ReplicationControlManagerInklessTest,RequestResponseTest,ApiKeysTest,MessageTest,RequestQuotaTest,ControllerApisTest,ReplicaManagerInklessTest,AbstractControlPlaneTestsubclasses, andAvailabilityGatedControlPlaneTest.InklessTopicTypeSwitcherClusterTestpasses. The newtestAlterDisklessSwitchRejectsReArmAndNonLowerSealOnCommittedSwitchswitches a topic, waits for the seal to commit, and checks that the controller rejects-2,-1, the committed seal, and a higher seal, and keeps the seal.ClassicToDisklessSwitchLastKnownLeaderClusterTestpasses in both cases. WithloseTail=true, it lowers the seal withalterDisklessSwitch, restarts the leader without runningrepair, finishes the switch, and reads the expected records from offset 0.ReplicationControlManagerInklessTestcases check thatalterDisklessSwitchlowers a committed seal in phase 1, keeps the leader epoch and the producer states, and writes a record that survives serialization. They also check that it rejects a seal on a pending switch, a lower seal in phase 2, on a classic topic, or on an unknown partition, a seal that isn't lower than the committed one, and every negative seal offset other than-2.TopicSwitchCommandTestchecks thatlower-sealrejects-2and-1without sending a request.testRearmAfterLoweringMinIsrLetsAStuckPendingSwitchReachTheSealputs a leader in a pending switch with its ISR belowmin.insync.replicas. Lowering the config leaves the high watermark in place, and therearmrecord advances it to the log end offset and registers the partition again.testConsolidatingSwitchSealsRegistersThenStartsConsolidationOnClassicPrefixFlagCommitcovers the restarted leader: a first delta from an empty image doesn't register the partition, and the record thatrearmwrites does.testFetchConsolidatingDisklessSwitchPendingReadsFromUnifiedLogWhenConsolidationEnabledcovers consumer reads from a pending partition.🤖 Generated with Claude Code