In Kafka, the topic is not getting leader after recreation post deletion

37 views Asked by At

Topic recreated after deletion does not have Leader defined. ISR is also empty. I have a kafka cluster of 3 nodes managed under 3 node Zookeeper ensemble.

Kafka - 2.5.8 and zookeeper 3.4.7

I had a topic called "Daily-heartbeat-G1" and this topic was deleted and recreated.

The topic was deleted from zookeeper directly as below :

Logged into Zookeeper CLI and ran below commands

rmr /brokers/topics/Daily-heartbeat-G1 rmr /config/topics/Daily-heartbeat-G1 rmr /admin/delete_topics/Daily-heartbeat-G1

Post this, topic was not getting listed.

Also deleted the corresponding directories from the kafka brokers as it were still present.

Now when we recreated the same topic with same name,it is showing Leader as "None" and ISR as empty.

I have not restarted the brokers after this though.

The questions I have is :

  1. What is causing Topic to not have Leader or why ISR is empty for such recreated topics? the other freshly created topics are fine.
  2. Should I have restarted the brokers after this deletion and recreation?
  3. Does it affect even if I dont delete the topic from kafka cli and directly delete it from zookeeper as shown above?

Have I missed anything out in this above process

1

There are 1 answers

2
Sara M. On

The Kafka brokers maintain the topic metadata, including the leader and ISR information. When you deleted a topic directly in ZooKeeper, you removed the topic's metadata. Creating a new topic with the same name doesn't automatically regenerate the metadata.

Directly deleting topics from ZooKeeper is not recommended. It's safer to delete topics using the Kafka CLI (kafka-topics.sh or equivalent) because it properly updates the metadata.

You can try to refresh the metadata cache or restart the Kafka brokers.