0xffff-zhiyan commented on PR #20242: URL: https://github.com/apache/kafka/pull/20242#issuecomment-3128850864
> Hey Zhiyan, thanks for the change - had a few questions! 1. > > > If a topic is created and then removed before the TopicsDelta is applied, we end up with the deleted topic in createdTopics on the delta but not in deletedTopicIds. > > The deleted topic isn't added to deletedTopicIds? Doesn't L141 show that it is added? **No it won't because if the topic is created before the TopicsDelta is applied, the existing image won't "find" it: The logic of RemoveTopicRecord :** `if (image.topicsById().containsKey(record.topicId())) {deletedTopicIds.add(record.topicId());}` **if we do a TopicRecord(adding the topic to createdTopics) and RemoveTopicRecord(not removing it from createdTopics) in the same batch, we end up with the deleted topic in createdTopics on the delta but not in deletedTopicIds.** > 2. What is the consequence of this bug - does the topic not get deleted properly or is there a fatal error that gets thrown? **It may cause some error whenever we do something with `createdTopics` (like when replaying ClearElrRecord we'll search `createdTopics` first)** **We haven't observed such error because it's impossible to see a TopicRecord and RemoveTopicRecord in the same batch, the only way this could surface is if MetadataLoader did some buffering(or not). But we'd better fix it before it really happens.** > 3. This change seems like it should be testable, any new tests we need/tests we can update? **Yes I can create a test doing a TopicRecord and RemoveTopicRecord in same batch and check if the createdTopics doesn't have a deleted topic at last** -- 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