KAFKA-20295: bridge pre-KIP-1312 controller decommissioning - #23196
Closed
davide-armand wants to merge 1 commit into
Closed
KAFKA-20295: bridge pre-KIP-1312 controller decommissioning#23196davide-armand wants to merge 1 commit into
davide-armand wants to merge 1 commit into
Conversation
davide-armand
force-pushed
the
davide-armand/KAFKA-20295-unregister-controller-patch--4.4
branch
from
August 19, 2026 13:39
3bdf9ef to
37c305e
Compare
KIP-1312 can unregister a controller only after `metadata.version`
reaches 4.4. Old, stopped controller registrations ("ghost
controllers") can advertise only older metadata versions, so feature
validation rejects the `metadata.version` upgrade needed to remove them
(deadlock situation).
This PR solves that deadlock by bridging the pre-KIP-1312 implementation
(PR #70:
#70) with KIP-1312.
Before 4.4-IV2, it marks a stopped controller that is no longer a quorum
voter with `__decommissioned_controller`. Patched controllers ignore
marked registrations during feature validation, allowing
`metadata.version` to reach 4.4. Afterwards, running the same operation
writes an `UnregisterControllerRecord` and deletes the registration
(KIP-1312 behavior).
This retains the useful marker from PR #70 and validation filter , but
changes its integration with Kafka. PR #70 introduced a fork-local
`DecommissionController` protocol and always retained the marked
registration, while also widening its advertised feature ranges. This
port reuses the upstream KIP-1312 UnregisterController API, preserves
the stored feature ranges, and physically removes the registration once
4.4 is finalized.
Without this PR, the following happens when doing a rolling upgrade for example
from 4.0 to 4.4:
1. Regular rolling upgrade operations (4.4 nodes up, 4.0 nodes down)
2. Unregister 4.0 brokers --> OK
3. Unregister 4.0 controllers using KIP-1312 --> KO
This fails because 4.0 ghost controllers don't have KIP-1312, so they cannot be unregistered:
```
[root@davide-armand-test-n1313 ~]# $K_BIN/kafka-cluster.sh unregister-controller --bootstrap-controller "$K_CONTROLLER_BOOTSTRAP" --id 6
Unregistering controller 10006
[2026-08-18 10:00:25,329] ERROR [AdminClient clientId=adminclient-1] Unregister controller request for controller ID 10006
failed: The current MetadataVersion is too old to support controller unregistration.
(org.apache.kafka.clients.admin.KafkaAdminClient)
The target cluster does not support the controller unregistration API.
```
4. Upgrade metadata version --> KO
This fails because 4.0 ghost controllers could not be unregistered at step 3:
```
[root@davide-armand-test-n1313 ~]# $K_BIN/kafka-features.sh --bootstrap-server "$K_BOOTSTRAP" upgrade --release-version 4.4-IV2 --dry-run
Can not upgrade eligible.leader.replicas.version to 1. The update failed for all features since the following feature had an error: Invalid update version 33 for feature metadata.version. Controller 10006 only supports versions 7-25
Can not upgrade group.version to 1. The update failed for all features since the following feature had an error: Invalid update version 33 for feature metadata.version. Controller 10006 only supports versions 7-25
Can not upgrade kraft.version to 1. The update failed for all features since the following feature had an error: Invalid update version 33 for feature metadata.version. Controller 10006 only supports versions 7-25
Can not upgrade metadata.version to 33. The update failed for all features since the following feature had an error: Invalid update version 33 for feature metadata.version. Controller 10006 only supports versions 7-25
Can not upgrade share.version to 2. The update failed for all features since the following feature had an error: Invalid update version 33 for feature metadata.version. Controller 10006 only supports versions 7-25
Can not upgrade streams.version to 1. The update failed for all features since the following feature had an error: Invalid update version 33 for feature metadata.version. Controller 10006 only supports versions 7-25
Can not upgrade transaction.version to 2. The update failed for all features since the following feature had an error: Invalid update version 33 for feature metadata.version. Controller 10006 only supports versions 7-25
7 out of 7 operation(s) failed.
```
Co-authored-by: Pi Agent (gpt-5.6-terra)
davide-armand
force-pushed
the
davide-armand/KAFKA-20295-unregister-controller-patch--4.4
branch
from
August 19, 2026 14:33
37c305e to
c294b2c
Compare
davide-armand
added a commit
to aiven/kafka
that referenced
this pull request
Aug 20, 2026
Clarify that marker cleanup happens through the 4.4+ forward-port after metadata.version finalization, and document that the target controller must be stopped before decommissioning. Forward-port implementation: apache#23196 Co-authored-by: Pi Agent (gpt-5.6-terra)
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.
KIP-1312 can unregister a controller only after
metadata.versionreaches 4.4. Old, stopped controller registrations ("ghost
controllers") can advertise only older metadata versions, so feature
validation rejects the
metadata.versionupgrade needed to remove them(deadlock situation).
This PR solves that deadlock by bridging the pre-KIP-1312 implementation
(PR #70) with KIP-1312.
Before 4.4-IV2, it marks a stopped controller that is no longer a quorum
voter with
__decommissioned_controller. Patched controllers ignoremarked registrations during feature validation, allowing
metadata.versionto reach 4.4. Afterwards, running the same operationwrites an
UnregisterControllerRecordand deletes the registration(KIP-1312 behavior).
This retains the useful marker from PR #70 and validation filter , but
changes its integration with Kafka. PR #70 introduced a fork-local
DecommissionControllerprotocol and always retained the markedregistration, while also widening its advertised feature ranges. This
port reuses the upstream KIP-1312 UnregisterController API, preserves
the stored feature ranges, and physically removes the registration once
4.4 is finalized.
Without this PR, the following happens when doing a rolling upgrade for example
from 4.0 to 4.4:
This fails because 4.0 ghost controllers don't have KIP-1312, so they cannot be unregistered:
This fails because 4.0 ghost controllers could not be unregistered at step 3:
Co-authored-by: Pi Agent (gpt-5.6-terra)