0
votes

I was using a kafka topic, and it's metadata as well in my application. I hard deleted the topic from the zookeeper shell, by deleting the directories corresponding to that topic. After creating the topic again, I described the topic and found that no leaders have been assigned to this newly created topic. In the consumer, I can see repeated logs printing LEADER_NOT_AVAILABLE. Any reason as to what am I doing wrong? Or maybe is there a way to delete the metadata related to the kafka topic as well that I'm unaware of? Thanks in advance!

1

1 Answers

0
votes

Deleting topics in Kafka hasn't been straightforward until recently. In general, you shouldn't attempt to delete Kafka topics by deleting metadata in Zookeeper. You should always use the included command line utilities.

First you need to make sure that deleting topics is enabled in the server.properties file on all brokers, and do a rolling restart if needed:

delete.topic.enable=true

After you restart the brokers to enable topic deletion, you should issue the delete command using the command line utilities:

./kafka-topics.sh —zookeeper <zookeeper_host>:2181 —delete —topic <topic_name>

If at this point, it's still stuck, try to run these two commands from the zookeeper shell to make sure and remove all metadata for that particular topic:

rmr /brokers/topics/<topic_name>
rmr /admin/delete_topics/<topic_name>

A few more details here:

https://medium.com/@contactsunny/manually-delete-apache-kafka-topics-424c7e016ff3