chickenchickenlove commented on code in PR #21127:
URL: https://github.com/apache/kafka/pull/21127#discussion_r2751251505
##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/OffsetFetcher.java:
##########
@@ -271,8 +273,23 @@ private void validatePositionsAsync(Map<TopicPartition,
FetchPosition> partition
subscriptions.setNextAllowedRetry(fetchPositions.keySet(),
nextResetTimeMs);
+ // Convert TopicPartition to TopicIdPartition
+ Map<TopicIdPartition, FetchPosition> fetchPositionsWithId = new
HashMap<>();
+ Map<String, Uuid> topicIds = metadata.topicIds();
+ fetchPositions.forEach((tp, position) -> {
+ Uuid topicId = topicIds.get(tp.topic());
+ if (topicId != null) {
+ TopicIdPartition tip = new TopicIdPartition(topicId, tp);
+ fetchPositionsWithId.put(tip, position);
+ } else {
+ // Topic ID not available yet, skip this partition for now
+ // The metadata will be refreshed and we'll retry
+ log.debug("Skipping offset validation for partition {}
because topic ID is not available in metadata", tp);
+ }
+ });
Review Comment:
I may be missing some context, but it looks like this path assumes that if a
topic doesn’t have a `TopicId` in `metadata.topicIds()`, it will eventually get
one and validation will proceed later. In migration / mixed-version
environments, I’m wondering if it’s plausible that many topics may not have
`TopicIds` for some time (or possibly indefinitely, depending on broker support
/ metadata propagation).
If that’s the case, should we handle the “missing TopicId” case explicitly
here — e.g., fall back to a name-based request (older protocol version such as
`v4`), or consider sending `Uuid.ZERO_UUID` for those partitions if that’s the
intended compatibility path? Otherwise, my concern is that some
`TopicPartitions` could be silently omitted from the `OffsetsForLeaderEpoch`
request and remain unvalidated.
Does that concern make sense, or is there an earlier step that guarantees
TopicIds will be present by the time we reach this code?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]