KAFKA-20839: Fix metadata.version stuck at MINIMUM_KRAFT_VERSION when… - #22954
Open
gp1314 wants to merge 1 commit into
Open
KAFKA-20839: Fix metadata.version stuck at MINIMUM_KRAFT_VERSION when…#22954gp1314 wants to merge 1 commit into
gp1314 wants to merge 1 commit into
Conversation
… controller activation loses leadership race When a KRaft controller is activated on a non-empty log that lacks a FeatureLevelRecord for metadata.version, the recordsForNonEmptyLog method previously only logged a warning but did not write the missing record. This caused the cluster's metadata.version to remain permanently stuck at MINIMUM_KRAFT_VERSION (3.0-IV1), breaking KIP-919 features such as --bootstrap-controller and dynamic controller management. Fix this by writing a FeatureLevelRecord with the correct metadata.version from BootstrapMetadata when this condition is detected, matching the intended behavior that was lost due to a leadership race during initial bootstrap record generation.
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.
Description
When a KRaft controller is activated on a non-empty metadata log that lacks a FeatureLevelRecord for metadata.version, the ActivationRecordsGenerator.recordsForNonEmptyLog() method only logs a warning but does not write the missing record. This causes
FeatureControlManager to fall back to MINIMUM_KRAFT_VERSION (3.0-IV1), and the cluster's metadata.version remains permanently stuck at this value.
Root Cause
This happens when the controller loses a leadership race during initial bootstrap activation:
Impact
Reproduction
kafka-features.sh --bootstrap-server broker:9092 describe
Fix
In ActivationRecordsGenerator.recordsForNonEmptyLog(), when the current metadataVersion equals MINIMUM_KRAFT_VERSION and the log lacks a FeatureLevelRecord, write one using the version from BootstrapMetadata (which was correctly set during kafka-storage format).
Workaround
Users affected by this bug can manually upgrade metadata.version after the controller stabilizes:
kafka-features.sh --bootstrap-server broker:9092 upgrade --feature metadata.version=3.9