0

why when deleting one topic in Kafka by this command :

/opt/kafka/confluent-4.0.0/bin/kafka-topics --zookeeper 109.169.xxx.xx:2181  --delete --topic test

and again see the list of Topics again, This message appears?

test - marked for deletion
Giorgos Myrianthous
  • 36,235
  • 20
  • 134
  • 156
Alihossein shahabi
  • 4,034
  • 2
  • 33
  • 53

2 Answers2

2

In Kafka, topic deletion is asynchronous. When you run the kafka-topics tool with --delete, you are simply marking the topic for deletion.

The actual deletion happens in most cases shortly after but depending on the state of your cluster it can be delayed.

In case it gets stuck, bouncing the controller usually helps.

Mickael Maison
  • 25,067
  • 7
  • 71
  • 68
2

If after a long time your topic is not deleted then make sure that delete.topic.enable in server.properties is set to true (although confluent 4.0.0 comes with this configuration). If you still face the same issue you can manually delete the topic by logging into Zookeeper using

zookeeper-shell localhost:2181

Now you can remove the topic using

rmr /brokers/topics/{topic_name}
rmr /admin/delete_topics/{topic_name}

Note that you might need to delete topic folder from Kafka broker machine before logging into ZK in order to manually remove the topic.

Giorgos Myrianthous
  • 36,235
  • 20
  • 134
  • 156