During debugging a problem with delete topic,I dig into Kafka code to know how delete command works, this the sequence of event occurred during command execution
2. which create a new admin path /admin/delete_topics/<topic>
3. The controller listens for child changes on /admin/delete_topic and starts topic deletion for the respective topics
4. The controller has a background thread that handles topic deletion. A topic's deletion can be started only by the onPartitionDeletion callback on the controller.
5. Once DeleteTopicsThread invoked it looks for topicsToBeDeleted and for each topic it deregister partition change listener on the deleted topic, This is to prevent the partition change listener firing before the new topic listener when a deleted topic gets auto created.
6. Controller will remove this replica from the state machine as well as its partition assignment cache.
7. Deletes all topic state from the controllerContext as well as from zookeeper and finally delete /brokers/topics/<topic> path. 8. onTopicDeletion is callback by the DeleteTopicThread,This lets each broker know that this topic is being deleted and can be removed from their caches.