KAFKA-20364: Remove control records reads from metadata module#22164
Open
xxxxxxjun wants to merge 2 commits intoapache:trunkfrom
Open
KAFKA-20364: Remove control records reads from metadata module#22164xxxxxxjun wants to merge 2 commits intoapache:trunkfrom
xxxxxxjun wants to merge 2 commits intoapache:trunkfrom
Conversation
xxxxxxjun
commented
Apr 28, 2026
Comment on lines
-535
to
-538
| assertThrows( | ||
| NullPointerException.class, | ||
| () -> loader.metrics().finalizedFeatureLevel(KRaftVersion.FEATURE_NAME) | ||
| ); |
Contributor
Author
There was a problem hiding this comment.
This no longer holds — kraft.version is registered on every publish, regardless of control records.
xxxxxxjun
commented
Apr 28, 2026
| setThreadNamePrefix(s"kafka-${sharedServerConfig.nodeId}-"). | ||
| setFaultHandler(metadataLoaderFaultHandler). | ||
| setHighWaterMarkAccessor(() => _raftManager.client.highWatermark()). | ||
| setKraftVersionSupplier(() => _raftManager.client.kraftVersion()). |
Contributor
Author
There was a problem hiding this comment.
This lambda runs at publish time, after _raftManager.startup() above has initialized the client.
xxxxxxjun
commented
Apr 28, 2026
Comment on lines
+401
to
+407
| // kraft.version is intentionally excluded from FeaturesImage (KAFKA-18979), | ||
| // so source it from the raft client instead of reading the control record directly. | ||
| metrics.recordFinalizedFeatureLevel( | ||
| KRaftVersion.FEATURE_NAME, | ||
| kraftVersionSupplier.get().featureLevel() | ||
| ); | ||
|
|
Contributor
Author
There was a problem hiding this comment.
The early return above skips this during catch-up, same as the other feature levels.
xxxxxxjun
commented
Apr 28, 2026
| setThreadNamePrefix(s"kafka-${sharedServerConfig.nodeId}-"). | ||
| setFaultHandler(metadataLoaderFaultHandler). | ||
| setHighWaterMarkAccessor(() => _raftManager.client.highWatermark()). | ||
| setKraftVersionSupplier(() => _raftManager.client.kraftVersion()). |
Contributor
Author
There was a problem hiding this comment.
RaftClient.kraftVersion() can return the requested (uncommitted) version on the leader during a kraft.version upgrade (FeatureControlManager uses the same source). A strict finalized source would need a new raft API. Should I address this here?
MetadataLoader.loadControlRecords() parsed KRAFT_VERSION control records to update the kraftVersion metric. This coupled the metadata module to raft's internal control record format. Source the value from the raft client through a Supplier<KRaftVersion> on MetadataLoader.Builder and record it in maybePublishMetadata() with the other feature levels. The update happens at publish time instead of per batch, so kraftVersion is gated on catch-up like the others. The metric name and value are unchanged.
8ebb8f3 to
83416fc
Compare
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.
MetadataLoader.loadControlRecords() parsed KRAFT_VERSION control records
to update the kraftVersion metric, which leaked raft's internal control
record format into the metadata module. Source the value from the raft
client through a Supplier on MetadataLoader.Builder, and
record it in maybePublishMetadata() with the other feature levels.
The update moves from the per-batch path to the publish path, so
kraftVersion is gated on catch-up like the other feature levels. The
metric name is unchanged.