showuon commented on code in PR #15335: URL: https://github.com/apache/kafka/pull/15335#discussion_r1544263703
########## core/src/main/scala/kafka/server/metadata/BrokerMetadataPublisher.scala: ########## @@ -289,13 +289,17 @@ class BrokerMetadataPublisher( try { // Start log manager, which will perform (potentially lengthy) // recovery-from-unclean-shutdown if required. - logManager.startup(metadataCache.getAllTopics()) - - // Delete partition directories which we're not supposed to have. We have - // to do this before starting ReplicaManager, so that the stray replicas - // don't block creation of new ones with different IDs but the same names. - // See KAFKA-14616 for details. - logManager.deleteStrayKRaftReplicas(brokerId, newImage.topics()) + logManager.startup( + metadataCache.getAllTopics(), + isStray = (topicId, partition) => { + val tid = topicId.getOrElse { + throw new RuntimeException(s"Partition $partition does not have a topic ID, " + + "which is not allowed when running in KRaft mode.") + } + Option(newImage.topics().getPartition(tid, partition.partition())) + .exists(_.replicas.contains(brokerId)) Review Comment: In original `findStrayReplicas`, we'll treat 2 cases as stray: 1. newImage doesn't contain the topic ID 2. newImage contains the topicID, but doesn't include this replica Here, we only treat case (2) as stray, not (1). Could I know what's the reason? Also, why can't we invoke `findStrayReplicas` or `isStrayReplicas` after your change? -- 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