You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by 方晓兵 <94...@gmail.com> on 2021/10/11 10:06:53 UTC

Why need handle delete topic in topic change event

Hi Team, 

I have a problem when I study kafka code in version 2.8.0.

I see `controllerContext.removeTopic(topic)` have been called in `TopicDeletionManager.completeDeleteTopic()`. TopicChangeHandler not only listen to child delete but also listen to child add. So every time a topic is deleted, an invalid event will be triggered because `controllerContext.removeTopic(topic)` have been called in `TopicDeletionManager.completeDeleteTopic()` after delete this topic zookeeper path. Is it code that needs to be optimized?

Grateful and look forward to answers

Re: Why need handle delete topic in topic change event

Posted by Colin McCabe <cm...@apache.org>.
On Mon, Oct 11, 2021, at 03:06, 方晓兵 wrote:
> Hi Team, 
>
> I have a problem when I study kafka code in version 2.8.0.
>
> I see `controllerContext.removeTopic(topic)` have been called in 
> `TopicDeletionManager.completeDeleteTopic()`. TopicChangeHandler not 
> only listen to child delete but also listen to child add. So every time 
> a topic is deleted, an invalid event will be triggered because 
> `controllerContext.removeTopic(topic)` have been called in 
> `TopicDeletionManager.completeDeleteTopic()` after delete this topic 
> zookeeper path. Is it code that needs to be optimized?
>
> Grateful and look forward to answers

Hi,

This code is going away once we remove ZK mode, which is the eventual goal of KIP-500. So it's probably not worth spending a lot of time on optimizing it.

Also, I was under the impression that ZooKeeper only gives you an EventType.NodeChildrenChanged, regardless of whether children were added, removed, or both. So I'm not sure how you would optimize this in the context of the old controller.

best,
Colin