soarez commented on code in PR #14881: URL: https://github.com/apache/kafka/pull/14881#discussion_r1420873183
########## metadata/src/main/java/org/apache/kafka/image/TopicDelta.java: ########## @@ -158,11 +160,21 @@ public LocalReplicaChanges localChanges(int brokerId) { new LocalReplicaChanges.PartitionInfo(id(), entry.getValue()) ); topicIds.putIfAbsent(name(), id()); + updateDirectoryIds(brokerId, entry, prevPartition, directoryIds); Review Comment: We should only add the directoryId as a local change if `prevPartition == null || prevPartition.directory(brokerId) != entry.getValue().directory(brokerId)`. So this change should be outside of the leader/follower conditions. Also I think the info we want/need is a map of `org.apache.kafka.common.TopicIdPartition` (which already includes the topicId – it's always present in KRaft mode) to `Uuid` (the directoryId in the metadata). We can get these as: ```java if (Replicas.contains(entry.getValue().replicas, brokerId)) { PartitionRegistration prevPartition = image.partitions().get(entry.getKey()); if (prevPartition == null || prevPartition.directory(brokerId) != entry.getValue().directory(brokerId)) { directoryIds.put( new TopicIdPartition(id(), entry.getKey(), name()), entry.getValue().directory(brokerId) ); } } ``` ########## metadata/src/main/java/org/apache/kafka/image/TopicDelta.java: ########## @@ -158,11 +160,21 @@ public LocalReplicaChanges localChanges(int brokerId) { new LocalReplicaChanges.PartitionInfo(id(), entry.getValue()) ); topicIds.putIfAbsent(name(), id()); + updateDirectoryIds(brokerId, entry, prevPartition, directoryIds); Review Comment: We should only add the directoryId as a local change if `prevPartition == null || prevPartition.directory(brokerId) != entry.getValue().directory(brokerId)`. So this change should be outside of the leader/follower conditions. Also I think the info we want/need is a map of `org.apache.kafka.common.TopicIdPartition` (which already includes the topicId – it's always present in KRaft mode) to `Uuid` (the directoryId in the metadata). We can get these as: ```java if (Replicas.contains(entry.getValue().replicas, brokerId)) { PartitionRegistration prevPartition = image.partitions().get(entry.getKey()); if (prevPartition == null || prevPartition.directory(brokerId) != entry.getValue().directory(brokerId)) { directoryIds.put( new TopicIdPartition(id(), entry.getKey(), name()), entry.getValue().directory(brokerId) ); } } ``` -- 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