chia7712 commented on code in PR #18685:
URL: https://github.com/apache/kafka/pull/18685#discussion_r1985530280


##########
core/src/main/scala/kafka/server/metadata/KRaftMetadataCache.scala:
##########
@@ -522,10 +522,14 @@ class KRaftMetadataCache(
     if (kraftVersionLevel > 0) {
       finalizedFeatures.put(KRaftVersion.FEATURE_NAME, kraftVersionLevel)
     }
+    var metadataVersion = MetadataVersion.MINIMUM_VERSION
+    if (!image.features().metadataVersion().isEmpty) {
+      metadataVersion = image.features().metadataVersionOrThrow()
+    }
     new FinalizedFeatures(
-      image.features().metadataVersionOrThrow(),
+      metadataVersion,
       finalizedFeatures,
-      image.highestOffsetAndEpoch().offset)
+      image.highestOffsetAndEpoch().epoch())

Review Comment:
   @junrao Thank you for your explanation. The following question may not be a 
real issue in Kafka, and I'm simply trying to learn more about the design.
   
   > In the client, the way that FinalizedFeaturesEpoch is used is to decide 
which finalized features returned in ApiResponse is the latest.
   
   The `FinalizedFeaturesEpoch` keeps increasing over time (due to 
`NoOpRecord`), so how do we use it to determine the "latest" ApiResponse, since 
the value is always greater than the previous ApiResponse?
   
    For example: Clients may periodically update the `ApiResponse` and compare 
the latest `FinalizedFeaturesEpoch` with their local cached 
`FinalizedFeaturesEpoch`. If the latest `FinalizedFeaturesEpoch` is greater 
than the local cached `FinalizedFeaturesEpoch`, clients initiate local feature 
changes. However, since the latest `FinalizedFeaturesEpoch` is always greater 
than the local cached `FinalizedFeaturesEpoch`, checking it becomes unnecessary.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to