Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When/how does a topic "marked for deletion" get finally removed?

Tags:

apache-kafka

I have issued the command to delete a topic:

./bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic  vip_ips_alerts 

It seemed to give a happy response:

[2014-05-31 20:58:10,112] INFO zookeeper state changed (SyncConnected) (org.I0Itec.zkclient.ZkClient) Topic "vip_ips_alerts" queued for deletion. 

But now 10 minutes later the topic still appears in the --list command:

./bin/kafka-topics.sh --zookeeper localhost:2181 --list vip_ips_alerts - marked for deletion 

So what does that mean? When will the topic be really deleted? How do I expedite this process?

like image 771
WestCoastProjects Avatar asked Jun 01 '14 04:06

WestCoastProjects


People also ask

What happens when you delete a Kafka topic?

Manually delete a topic with Zookeeper After you issue the delete command, the topic will be “marked for deletion,' and you'll have to wait till it gets deleted. Sometimes, it doesn't happen.

How do I remove something from a Kafka topic?

This can be done using the kafka-delete-records.sh tool to read a configuration file (JSON format) that describes the records we want to be deleted. The example in the listing below can be used to remove all messages from the test-topic created earlier. The contents of the file should be saved as delete-test.


2 Answers

tl;dr Set delete.topic.enable = true in config/server.properties of Kafka brokers and...be patient.

It happens with the latest development version of Kafka 0.8.3-SNAPSHOT:

➜  kafka_2.11-0.8.3-SNAPSHOT git:(trunk) ✗ ./bin/kafka-topics.sh --zookeeper localhost:2181 --create --topic my-topic --partitions 2 --replication-factor 1 Created topic "my-topic".  ➜  kafka_2.11-0.8.3-SNAPSHOT git:(trunk) ✗ ./bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic my-topic Topic:my-topic  PartitionCount:2    ReplicationFactor:1 Configs:     Topic: my-topic Partition: 0    Leader: 0   Replicas: 0 Isr: 0     Topic: my-topic Partition: 1    Leader: 0   Replicas: 0 Isr: 0  ➜  kafka_2.11-0.8.3-SNAPSHOT git:(trunk) ✗ ./bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic my-topic Topic my-topic is marked for deletion. Note: This will have no impact if delete.topic.enable is not set to true.  ➜  kafka_2.11-0.8.3-SNAPSHOT git:(trunk) ✗ ./bin/kafka-topics.sh --zookeeper localhost:2181 --list ➜  kafka_2.11-0.8.3-SNAPSHOT git:(trunk) ✗ 

The point is to have delete.topic.enable=true in config/server.properties that you use to start a Kafka broker.

➜  kafka_2.11-0.8.3-SNAPSHOT git:(trunk) ✗ grep delete.topic.enable config/server.properties delete.topic.enable=true 

You can also ensure the setting be true in a broker's log:

➜  kafka_2.11-0.8.3-SNAPSHOT git:(trunk) ✗ ./bin/kafka-server-start.sh config/server.properties [2015-07-24 22:33:26,184] INFO KafkaConfig values:         ...         delete.topic.enable = true 
like image 165
Jacek Laskowski Avatar answered Sep 28 '22 01:09

Jacek Laskowski


In my case where i am using Kafka 8.2.2, I had to delete entries from the following manually -

  1. Delete topic folder from Kafka broker machine.
  2. Login to zookeeper and -

    hbase zkcli rmr /brokers/topics/{topic_name} rmr /admin/delete_topics/{topic_name} 
like image 33
tesnik03 Avatar answered Sep 28 '22 00:09

tesnik03