Community Articles

Find and share helpful community-sourced technical articles.
Announcements
Celebrating as our community reaches 100,000 members! Thank you!
Labels (1)
avatar
Super Guru

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

1. TopicCommand issues topic deletion

/usr/hdp/current/kafka-broker/bin/kafka-run-class.sh kafka.admin.TopicCommand --zookeeper rkk3.hdp.local:2181 --delete --topic sample 

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.

17,804 Views
Version history
Last update:
‎12-19-2016 12:40 PM
Updated by:
Contributors