Repository navigation
feat(inkless:controller): gate ISR, reassignment, and leader election on switch phase - #833
Merged
Merged
Conversation
giuseppelillo
force-pushed
the
giuseppelillo/kc-586-switch-phase-rules
branch
from
October 21, 2026 12:39
a853b50 to
a01dbe1
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved transition handling can corrupt reassignment targets, leave partitions leaderless, or stall follower catch-up.
3 open issues
What changed in this PR
This PR makes controller behavior follow the classic-to-diskless switch phase, preserving classic replica requirements until remote storage holds the prefix.
Changes:
- Gate ISR expansion, reassignment, and leader eligibility on switch phase.
- Reject seal changes after the remote-prefix flag commits.
- Add tests for phase-specific behavior and transitions.
| File | Description |
|---|---|
metadata/src/test/java/org/apache/kafka/controller/ReplicationControlManagerInklessTest.java |
Adds switch-phase and reassignment regression tests. |
metadata/src/main/java/org/apache/kafka/controller/ReplicationControlManager.java |
Applies phase-aware controller rules and protects committed seals. |
Review effort: Balanced
giuseppelillo
force-pushed
the
giuseppelillo/kc-586-switch-phase-rules
branch
from
October 21, 2026 13:11
12bfb37 to
84cf998
Compare
…iered Once classicPrefixInRemoteStorage is set, brokers delete their local prefix below the committed seal and start consolidating from it. Reject any seal modification (including lowering) once the flag is set. Assisted-by: Gemini 4 Argon
…election In phase 1 (seal present, classicPrefixInRemoteStorage unset), the classic prefix still lives on the replicas' local disks, so a broker whose replica directory is offline cannot safely become leader. Use LeaderAcceptor in both leaderAcceptorFor overloads while isSwitchedWithLocalClassicPrefix(partition) holds, and keep isActive-only for born-diskless and phase-2 partitions. Assisted-by: Gemini 4 Argon
giuseppelillo
force-pushed
the
giuseppelillo/kc-586-switch-phase-rules
branch
from
October 21, 2026 13:15
84cf998 to
6c46be6
Compare
…itions In phase 1 (seal present, classicPrefixInRemoteStorage unset), records below the seal exist only on the replicas' local disks, so a reassignment must use the staged adding/removing path until the new replicas catch up. Born-diskless and phase-2 partitions keep the one-step reassignment path. Retargeting a reassignment that is already in progress reconciles the inherited adding and removing replicas against the new target. A replica that is no longer requested leaves adding, a requested replica that hasn't caught up stays in adding, and the one-step path clears the previous move even when the new target equals the current replicas. Assisted-by: Gemini 4 Argon
giuseppelillo
force-pushed
the
giuseppelillo/kc-586-switch-phase-rules
branch
from
October 21, 2026 13:28
6c46be6 to
c2fc447
Compare
…artitions Once classicPrefixInRemoteStorage is set, a switched partition's classic prefix lives in remote storage and no replica relies on its local copy. Skip unfence ISR expansion only while isSwitchedWithLocalClassicPrefix(partition) holds, so phase-2 partitions re-add unfenced replicas (and complete in-flight reassignments) like born-diskless partitions. Assisted-by: Gemini 4 Argon Assisted-by: Claude Sonnet 5.5 Co-authored-by: Cursor <cursoragent@cursor.com>
The phase rules change how a switched partition handles reassignment, ISR expansion on unfence, and `AlterDisklessSwitch`. The docs still say that diskless reassignment is always immediate and that a returning broker rejoins the ISR at once. They don't describe the phases. The `seal` command also validates only the offset range, so `--dry-run` reports an action that the controller rejects in phase 2. Add a "Switch phases" section to `CLASSIC_TO_DISKLESS_SWITCH.md` and link it from `FEATURES.md`, `FAQ.md`, and `DISKLESS_CONSOLIDATION.md`. Document that the controller rejects every seal change once `classicPrefixInRemoteStorage` is set, in the operator override section, the `seal --offset` help, and the `Admin.alterDisklessSwitch` Javadoc. `kafka-topic-switch.sh seal` now fails with that reason when it reads the partition, which covers `--dry-run`. The `-1` and `-2` offsets don't read the partition, because controllers don't serve `DescribeTopicPartitions`. They keep working with `--bootstrap-controller`. Testing Run `TopicSwitchCommandTest`, the `clients` and `tools` checkstyle tasks, and `make vale`. Assisted-by: Claude Sonnet 5.5 Co-authored-by: Cursor <cursoragent@cursor.com>
giuseppelillo
force-pushed
the
giuseppelillo/kc-586-switch-phase-rules
branch
from
October 21, 2026 14:23
c2fc447 to
0b3cfd8
Compare
jeqo
reviewed
Oct 23, 2026
jeqo
left a comment
Contributor
There was a problem hiding this comment.
Found few minor changes, otherwise LGTM.
… command The controller rejects a seal offset that exceeds the committed seal, but `kafka-topic-switch.sh seal` only checked the classic log range. After a switch, the log end offset includes diskless data, so `--dry-run` reported "Would set" for a request the controller then rejects. The command now fails before it sends the request, and the help text and switch doc state the rule. The unfence ISR expansion comment now covers both cases where the unfencing broker is accepted as leader: a leaderless partition and a reassignment that removes the current leader. A new test pins the leaderless case for born-diskless partitions. The FAQ answer about a returning replica broker notes that a phase-1 switched topic rejoins the ISR through `AlterPartition`. ## Test plan - `ReplicationControlManagerInklessTest$DisklessManagedReplicasTests.testUnfenceElectsUnfencingBrokerForLeaderlessBornDisklessPartition`: fails with the previous `clusterControl::isActive` predicate and passes with the current one. - `TopicSwitchCommandTest`: `testSealRejectsExplicitOffsetAboveCommittedSeal`, `testSealDryRunRejectsExplicitOffsetAboveCommittedSeal`, and `testSealCommitsExplicitOffsetEqualToCommittedSeal`. Assisted-by: Claude Opus 5.5 Co-authored-by: Cursor <cursoragent@cursor.com>
jeqo
previously approved these changes
Oct 23, 2026
giuseppelillo
force-pushed
the
giuseppelillo/kc-586-switch-phase-rules
branch
from
October 23, 2026 11:59
6931a21 to
8888c31
Compare
Contributor
Author
|
Re-pushed as the first 2 commits were missing the signature |
…n docs Main inserts the untiered diskless migration guide in the same place as the phase-1 reassignment exception. Keep both so switched partitions still document staged reassignment while the prefix is local. Assisted-by: Grok 4.7 Co-authored-by: Cursor <cursoragent@cursor.com>
jeqo
approved these changes
Oct 23, 2026
viktorsomogyi
pushed a commit
that referenced
this pull request
Oct 29, 2026
… on switch phase (#833) * fix(inkless:controller): reject alterDisklessSwitch after prefix is tiered Once classicPrefixInRemoteStorage is set, brokers delete their local prefix below the committed seal and start consolidating from it. Reject any seal modification (including lowering) once the flag is set. Assisted-by: Gemini 4 Argon * fix(inkless:controller): require online directory for phase-1 leader election In phase 1 (seal present, classicPrefixInRemoteStorage unset), the classic prefix still lives on the replicas' local disks, so a broker whose replica directory is offline cannot safely become leader. Use LeaderAcceptor in both leaderAcceptorFor overloads while isSwitchedWithLocalClassicPrefix(partition) holds, and keep isActive-only for born-diskless and phase-2 partitions. Assisted-by: Gemini 4 Argon * fix(inkless:controller): stage reassignments of phase-1 switched partitions In phase 1 (seal present, classicPrefixInRemoteStorage unset), records below the seal exist only on the replicas' local disks, so a reassignment must use the staged adding/removing path until the new replicas catch up. Born-diskless and phase-2 partitions keep the one-step reassignment path. Retargeting a reassignment that is already in progress reconciles the inherited adding and removing replicas against the new target. A replica that is no longer requested leaves adding, a requested replica that hasn't caught up stays in adding, and the one-step path clears the previous move even when the new target equals the current replicas. Assisted-by: Gemini 4 Argon * fix(inkless:controller): expand ISR on unfence for phase-2 switched partitions Once classicPrefixInRemoteStorage is set, a switched partition's classic prefix lives in remote storage and no replica relies on its local copy. Skip unfence ISR expansion only while isSwitchedWithLocalClassicPrefix(partition) holds, so phase-2 partitions re-add unfenced replicas (and complete in-flight reassignments) like born-diskless partitions. Assisted-by: Gemini 4 Argon Assisted-by: Claude Sonnet 5.5 Co-authored-by: Cursor <cursoragent@cursor.com> * fix(inkless:switch): align docs and seal command with switch phases The phase rules change how a switched partition handles reassignment, ISR expansion on unfence, and `AlterDisklessSwitch`. The docs still say that diskless reassignment is always immediate and that a returning broker rejoins the ISR at once. They don't describe the phases. The `seal` command also validates only the offset range, so `--dry-run` reports an action that the controller rejects in phase 2. Add a "Switch phases" section to `CLASSIC_TO_DISKLESS_SWITCH.md` and link it from `FEATURES.md`, `FAQ.md`, and `DISKLESS_CONSOLIDATION.md`. Document that the controller rejects every seal change once `classicPrefixInRemoteStorage` is set, in the operator override section, the `seal --offset` help, and the `Admin.alterDisklessSwitch` Javadoc. `kafka-topic-switch.sh seal` now fails with that reason when it reads the partition, which covers `--dry-run`. The `-1` and `-2` offsets don't read the partition, because controllers don't serve `DescribeTopicPartitions`. They keep working with `--bootstrap-controller`. Testing Run `TopicSwitchCommandTest`, the `clients` and `tools` checkstyle tasks, and `make vale`. Assisted-by: Claude Sonnet 5.5 Co-authored-by: Cursor <cursoragent@cursor.com> * fix(inkless:switch): reject seals past the committed seal in the seal command The controller rejects a seal offset that exceeds the committed seal, but `kafka-topic-switch.sh seal` only checked the classic log range. After a switch, the log end offset includes diskless data, so `--dry-run` reported "Would set" for a request the controller then rejects. The command now fails before it sends the request, and the help text and switch doc state the rule. The unfence ISR expansion comment now covers both cases where the unfencing broker is accepted as leader: a leaderless partition and a reassignment that removes the current leader. A new test pins the leaderless case for born-diskless partitions. The FAQ answer about a returning replica broker notes that a phase-1 switched topic rejoins the ISR through `AlterPartition`. ## Test plan - `ReplicationControlManagerInklessTest$DisklessManagedReplicasTests.testUnfenceElectsUnfencingBrokerForLeaderlessBornDisklessPartition`: fails with the previous `clusterControl::isActive` predicate and passes with the current one. - `TopicSwitchCommandTest`: `testSealRejectsExplicitOffsetAboveCommittedSeal`, `testSealDryRunRejectsExplicitOffsetAboveCommittedSeal`, and `testSealCommitsExplicitOffsetEqualToCommittedSeal`. Assisted-by: Claude Opus 5.5 Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
viktorsomogyi
pushed a commit
that referenced
this pull request
Oct 29, 2026
… on switch phase (#833) * fix(inkless:controller): reject alterDisklessSwitch after prefix is tiered Once classicPrefixInRemoteStorage is set, brokers delete their local prefix below the committed seal and start consolidating from it. Reject any seal modification (including lowering) once the flag is set. Assisted-by: Gemini 4 Argon * fix(inkless:controller): require online directory for phase-1 leader election In phase 1 (seal present, classicPrefixInRemoteStorage unset), the classic prefix still lives on the replicas' local disks, so a broker whose replica directory is offline cannot safely become leader. Use LeaderAcceptor in both leaderAcceptorFor overloads while isSwitchedWithLocalClassicPrefix(partition) holds, and keep isActive-only for born-diskless and phase-2 partitions. Assisted-by: Gemini 4 Argon * fix(inkless:controller): stage reassignments of phase-1 switched partitions In phase 1 (seal present, classicPrefixInRemoteStorage unset), records below the seal exist only on the replicas' local disks, so a reassignment must use the staged adding/removing path until the new replicas catch up. Born-diskless and phase-2 partitions keep the one-step reassignment path. Retargeting a reassignment that is already in progress reconciles the inherited adding and removing replicas against the new target. A replica that is no longer requested leaves adding, a requested replica that hasn't caught up stays in adding, and the one-step path clears the previous move even when the new target equals the current replicas. Assisted-by: Gemini 4 Argon * fix(inkless:controller): expand ISR on unfence for phase-2 switched partitions Once classicPrefixInRemoteStorage is set, a switched partition's classic prefix lives in remote storage and no replica relies on its local copy. Skip unfence ISR expansion only while isSwitchedWithLocalClassicPrefix(partition) holds, so phase-2 partitions re-add unfenced replicas (and complete in-flight reassignments) like born-diskless partitions. Assisted-by: Gemini 4 Argon Assisted-by: Claude Sonnet 5.5 Co-authored-by: Cursor <cursoragent@cursor.com> * fix(inkless:switch): align docs and seal command with switch phases The phase rules change how a switched partition handles reassignment, ISR expansion on unfence, and `AlterDisklessSwitch`. The docs still say that diskless reassignment is always immediate and that a returning broker rejoins the ISR at once. They don't describe the phases. The `seal` command also validates only the offset range, so `--dry-run` reports an action that the controller rejects in phase 2. Add a "Switch phases" section to `CLASSIC_TO_DISKLESS_SWITCH.md` and link it from `FEATURES.md`, `FAQ.md`, and `DISKLESS_CONSOLIDATION.md`. Document that the controller rejects every seal change once `classicPrefixInRemoteStorage` is set, in the operator override section, the `seal --offset` help, and the `Admin.alterDisklessSwitch` Javadoc. `kafka-topic-switch.sh seal` now fails with that reason when it reads the partition, which covers `--dry-run`. The `-1` and `-2` offsets don't read the partition, because controllers don't serve `DescribeTopicPartitions`. They keep working with `--bootstrap-controller`. Testing Run `TopicSwitchCommandTest`, the `clients` and `tools` checkstyle tasks, and `make vale`. Assisted-by: Claude Sonnet 5.5 Co-authored-by: Cursor <cursoragent@cursor.com> * fix(inkless:switch): reject seals past the committed seal in the seal command The controller rejects a seal offset that exceeds the committed seal, but `kafka-topic-switch.sh seal` only checked the classic log range. After a switch, the log end offset includes diskless data, so `--dry-run` reported "Would set" for a request the controller then rejects. The command now fails before it sends the request, and the help text and switch doc state the rule. The unfence ISR expansion comment now covers both cases where the unfencing broker is accepted as leader: a leaderless partition and a reassignment that removes the current leader. A new test pins the leaderless case for born-diskless partitions. The FAQ answer about a returning replica broker notes that a phase-1 switched topic rejoins the ISR through `AlterPartition`. ## Test plan - `ReplicationControlManagerInklessTest$DisklessManagedReplicasTests.testUnfenceElectsUnfencingBrokerForLeaderlessBornDisklessPartition`: fails with the previous `clusterControl::isActive` predicate and passes with the current one. - `TopicSwitchCommandTest`: `testSealRejectsExplicitOffsetAboveCommittedSeal`, `testSealDryRunRejectsExplicitOffsetAboveCommittedSeal`, and `testSealCommitsExplicitOffsetEqualToCommittedSeal`. Assisted-by: Claude Opus 5.5 Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com> Assisted-by: Grok 4.7
gqmelo
pushed a commit
that referenced
this pull request
Nov 5, 2026
… on switch phase (#833) * fix(inkless:controller): reject alterDisklessSwitch after prefix is tiered Once classicPrefixInRemoteStorage is set, brokers delete their local prefix below the committed seal and start consolidating from it. Reject any seal modification (including lowering) once the flag is set. Assisted-by: Gemini 4 Argon * fix(inkless:controller): require online directory for phase-1 leader election In phase 1 (seal present, classicPrefixInRemoteStorage unset), the classic prefix still lives on the replicas' local disks, so a broker whose replica directory is offline cannot safely become leader. Use LeaderAcceptor in both leaderAcceptorFor overloads while isSwitchedWithLocalClassicPrefix(partition) holds, and keep isActive-only for born-diskless and phase-2 partitions. Assisted-by: Gemini 4 Argon * fix(inkless:controller): stage reassignments of phase-1 switched partitions In phase 1 (seal present, classicPrefixInRemoteStorage unset), records below the seal exist only on the replicas' local disks, so a reassignment must use the staged adding/removing path until the new replicas catch up. Born-diskless and phase-2 partitions keep the one-step reassignment path. Retargeting a reassignment that is already in progress reconciles the inherited adding and removing replicas against the new target. A replica that is no longer requested leaves adding, a requested replica that hasn't caught up stays in adding, and the one-step path clears the previous move even when the new target equals the current replicas. Assisted-by: Gemini 4 Argon * fix(inkless:controller): expand ISR on unfence for phase-2 switched partitions Once classicPrefixInRemoteStorage is set, a switched partition's classic prefix lives in remote storage and no replica relies on its local copy. Skip unfence ISR expansion only while isSwitchedWithLocalClassicPrefix(partition) holds, so phase-2 partitions re-add unfenced replicas (and complete in-flight reassignments) like born-diskless partitions. Assisted-by: Gemini 4 Argon Assisted-by: Claude Sonnet 5.5 Co-authored-by: Cursor <cursoragent@cursor.com> * fix(inkless:switch): align docs and seal command with switch phases The phase rules change how a switched partition handles reassignment, ISR expansion on unfence, and `AlterDisklessSwitch`. The docs still say that diskless reassignment is always immediate and that a returning broker rejoins the ISR at once. They don't describe the phases. The `seal` command also validates only the offset range, so `--dry-run` reports an action that the controller rejects in phase 2. Add a "Switch phases" section to `CLASSIC_TO_DISKLESS_SWITCH.md` and link it from `FEATURES.md`, `FAQ.md`, and `DISKLESS_CONSOLIDATION.md`. Document that the controller rejects every seal change once `classicPrefixInRemoteStorage` is set, in the operator override section, the `seal --offset` help, and the `Admin.alterDisklessSwitch` Javadoc. `kafka-topic-switch.sh seal` now fails with that reason when it reads the partition, which covers `--dry-run`. The `-1` and `-2` offsets don't read the partition, because controllers don't serve `DescribeTopicPartitions`. They keep working with `--bootstrap-controller`. Testing Run `TopicSwitchCommandTest`, the `clients` and `tools` checkstyle tasks, and `make vale`. Assisted-by: Claude Sonnet 5.5 Co-authored-by: Cursor <cursoragent@cursor.com> * fix(inkless:switch): reject seals past the committed seal in the seal command The controller rejects a seal offset that exceeds the committed seal, but `kafka-topic-switch.sh seal` only checked the classic log range. After a switch, the log end offset includes diskless data, so `--dry-run` reported "Would set" for a request the controller then rejects. The command now fails before it sends the request, and the help text and switch doc state the rule. The unfence ISR expansion comment now covers both cases where the unfencing broker is accepted as leader: a leaderless partition and a reassignment that removes the current leader. A new test pins the leaderless case for born-diskless partitions. The FAQ answer about a returning replica broker notes that a phase-1 switched topic rejoins the ISR through `AlterPartition`. ## Test plan - `ReplicationControlManagerInklessTest$DisklessManagedReplicasTests.testUnfenceElectsUnfencingBrokerForLeaderlessBornDisklessPartition`: fails with the previous `clusterControl::isActive` predicate and passes with the current one. - `TopicSwitchCommandTest`: `testSealRejectsExplicitOffsetAboveCommittedSeal`, `testSealDryRunRejectsExplicitOffsetAboveCommittedSeal`, and `testSealCommitsExplicitOffsetEqualToCommittedSeal`. Assisted-by: Claude Opus 5.5 Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
gqmelo
pushed a commit
that referenced
this pull request
Nov 5, 2026
… on switch phase (#833) * fix(inkless:controller): reject alterDisklessSwitch after prefix is tiered Once classicPrefixInRemoteStorage is set, brokers delete their local prefix below the committed seal and start consolidating from it. Reject any seal modification (including lowering) once the flag is set. Assisted-by: Gemini 4 Argon * fix(inkless:controller): require online directory for phase-1 leader election In phase 1 (seal present, classicPrefixInRemoteStorage unset), the classic prefix still lives on the replicas' local disks, so a broker whose replica directory is offline cannot safely become leader. Use LeaderAcceptor in both leaderAcceptorFor overloads while isSwitchedWithLocalClassicPrefix(partition) holds, and keep isActive-only for born-diskless and phase-2 partitions. Assisted-by: Gemini 4 Argon * fix(inkless:controller): stage reassignments of phase-1 switched partitions In phase 1 (seal present, classicPrefixInRemoteStorage unset), records below the seal exist only on the replicas' local disks, so a reassignment must use the staged adding/removing path until the new replicas catch up. Born-diskless and phase-2 partitions keep the one-step reassignment path. Retargeting a reassignment that is already in progress reconciles the inherited adding and removing replicas against the new target. A replica that is no longer requested leaves adding, a requested replica that hasn't caught up stays in adding, and the one-step path clears the previous move even when the new target equals the current replicas. Assisted-by: Gemini 4 Argon * fix(inkless:controller): expand ISR on unfence for phase-2 switched partitions Once classicPrefixInRemoteStorage is set, a switched partition's classic prefix lives in remote storage and no replica relies on its local copy. Skip unfence ISR expansion only while isSwitchedWithLocalClassicPrefix(partition) holds, so phase-2 partitions re-add unfenced replicas (and complete in-flight reassignments) like born-diskless partitions. Assisted-by: Gemini 4 Argon Assisted-by: Claude Sonnet 5.5 Co-authored-by: Cursor <cursoragent@cursor.com> * fix(inkless:switch): align docs and seal command with switch phases The phase rules change how a switched partition handles reassignment, ISR expansion on unfence, and `AlterDisklessSwitch`. The docs still say that diskless reassignment is always immediate and that a returning broker rejoins the ISR at once. They don't describe the phases. The `seal` command also validates only the offset range, so `--dry-run` reports an action that the controller rejects in phase 2. Add a "Switch phases" section to `CLASSIC_TO_DISKLESS_SWITCH.md` and link it from `FEATURES.md`, `FAQ.md`, and `DISKLESS_CONSOLIDATION.md`. Document that the controller rejects every seal change once `classicPrefixInRemoteStorage` is set, in the operator override section, the `seal --offset` help, and the `Admin.alterDisklessSwitch` Javadoc. `kafka-topic-switch.sh seal` now fails with that reason when it reads the partition, which covers `--dry-run`. The `-1` and `-2` offsets don't read the partition, because controllers don't serve `DescribeTopicPartitions`. They keep working with `--bootstrap-controller`. Testing Run `TopicSwitchCommandTest`, the `clients` and `tools` checkstyle tasks, and `make vale`. Assisted-by: Claude Sonnet 5.5 Co-authored-by: Cursor <cursoragent@cursor.com> * fix(inkless:switch): reject seals past the committed seal in the seal command The controller rejects a seal offset that exceeds the committed seal, but `kafka-topic-switch.sh seal` only checked the classic log range. After a switch, the log end offset includes diskless data, so `--dry-run` reported "Would set" for a request the controller then rejects. The command now fails before it sends the request, and the help text and switch doc state the rule. The unfence ISR expansion comment now covers both cases where the unfencing broker is accepted as leader: a leaderless partition and a reassignment that removes the current leader. A new test pins the leaderless case for born-diskless partitions. The FAQ answer about a returning replica broker notes that a phase-1 switched topic rejoins the ISR through `AlterPartition`. ## Test plan - `ReplicationControlManagerInklessTest$DisklessManagedReplicasTests.testUnfenceElectsUnfencingBrokerForLeaderlessBornDisklessPartition`: fails with the previous `clusterControl::isActive` predicate and passes with the current one. - `TopicSwitchCommandTest`: `testSealRejectsExplicitOffsetAboveCommittedSeal`, `testSealDryRunRejectsExplicitOffsetAboveCommittedSeal`, and `testSealCommitsExplicitOffsetEqualToCommittedSeal`. Assisted-by: Claude Opus 5.5 Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
gqmelo
pushed a commit
that referenced
this pull request
Nov 5, 2026
… on switch phase (#833) * fix(inkless:controller): reject alterDisklessSwitch after prefix is tiered Once classicPrefixInRemoteStorage is set, brokers delete their local prefix below the committed seal and start consolidating from it. Reject any seal modification (including lowering) once the flag is set. Assisted-by: Gemini 4 Argon * fix(inkless:controller): require online directory for phase-1 leader election In phase 1 (seal present, classicPrefixInRemoteStorage unset), the classic prefix still lives on the replicas' local disks, so a broker whose replica directory is offline cannot safely become leader. Use LeaderAcceptor in both leaderAcceptorFor overloads while isSwitchedWithLocalClassicPrefix(partition) holds, and keep isActive-only for born-diskless and phase-2 partitions. Assisted-by: Gemini 4 Argon * fix(inkless:controller): stage reassignments of phase-1 switched partitions In phase 1 (seal present, classicPrefixInRemoteStorage unset), records below the seal exist only on the replicas' local disks, so a reassignment must use the staged adding/removing path until the new replicas catch up. Born-diskless and phase-2 partitions keep the one-step reassignment path. Retargeting a reassignment that is already in progress reconciles the inherited adding and removing replicas against the new target. A replica that is no longer requested leaves adding, a requested replica that hasn't caught up stays in adding, and the one-step path clears the previous move even when the new target equals the current replicas. Assisted-by: Gemini 4 Argon * fix(inkless:controller): expand ISR on unfence for phase-2 switched partitions Once classicPrefixInRemoteStorage is set, a switched partition's classic prefix lives in remote storage and no replica relies on its local copy. Skip unfence ISR expansion only while isSwitchedWithLocalClassicPrefix(partition) holds, so phase-2 partitions re-add unfenced replicas (and complete in-flight reassignments) like born-diskless partitions. Assisted-by: Gemini 4 Argon Assisted-by: Claude Sonnet 5.5 Co-authored-by: Cursor <cursoragent@cursor.com> * fix(inkless:switch): align docs and seal command with switch phases The phase rules change how a switched partition handles reassignment, ISR expansion on unfence, and `AlterDisklessSwitch`. The docs still say that diskless reassignment is always immediate and that a returning broker rejoins the ISR at once. They don't describe the phases. The `seal` command also validates only the offset range, so `--dry-run` reports an action that the controller rejects in phase 2. Add a "Switch phases" section to `CLASSIC_TO_DISKLESS_SWITCH.md` and link it from `FEATURES.md`, `FAQ.md`, and `DISKLESS_CONSOLIDATION.md`. Document that the controller rejects every seal change once `classicPrefixInRemoteStorage` is set, in the operator override section, the `seal --offset` help, and the `Admin.alterDisklessSwitch` Javadoc. `kafka-topic-switch.sh seal` now fails with that reason when it reads the partition, which covers `--dry-run`. The `-1` and `-2` offsets don't read the partition, because controllers don't serve `DescribeTopicPartitions`. They keep working with `--bootstrap-controller`. Testing Run `TopicSwitchCommandTest`, the `clients` and `tools` checkstyle tasks, and `make vale`. Assisted-by: Claude Sonnet 5.5 Co-authored-by: Cursor <cursoragent@cursor.com> * fix(inkless:switch): reject seals past the committed seal in the seal command The controller rejects a seal offset that exceeds the committed seal, but `kafka-topic-switch.sh seal` only checked the classic log range. After a switch, the log end offset includes diskless data, so `--dry-run` reported "Would set" for a request the controller then rejects. The command now fails before it sends the request, and the help text and switch doc state the rule. The unfence ISR expansion comment now covers both cases where the unfencing broker is accepted as leader: a leaderless partition and a reassignment that removes the current leader. A new test pins the leaderless case for born-diskless partitions. The FAQ answer about a returning replica broker notes that a phase-1 switched topic rejoins the ISR through `AlterPartition`. ## Test plan - `ReplicationControlManagerInklessTest$DisklessManagedReplicasTests.testUnfenceElectsUnfencingBrokerForLeaderlessBornDisklessPartition`: fails with the previous `clusterControl::isActive` predicate and passes with the current one. - `TopicSwitchCommandTest`: `testSealRejectsExplicitOffsetAboveCommittedSeal`, `testSealDryRunRejectsExplicitOffsetAboveCommittedSeal`, and `testSealCommitsExplicitOffsetEqualToCommittedSeal`. Assisted-by: Claude Opus 5.5 Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


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 fix(inkless:switch): stage reassignments of switched partitions #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