Mohammad Sunny
Mohammad Sunny

Reputation: 371

Topic doesn't exist as expected in kafka

After running this command :

bin/kafka-topics.bat --list --bootstrap-server localhost:6666, localhost:6667, localhost:6668, localhost:6669

Output - Test

After running this command :

bin/kafka-topics.bat --describe --bootstrap-server localhost:6666, localhost:6667, localhost:6668, localhost:6669 --topic Test

Error :

java.lang.IllegalArgumentException: Topic 'Test' does not exist as expected at kafka.admin.TopicCommand$.kafka$admin$TopicCommand$$ensureTopicExists(TopicCommand.scala:523) at kafka.admin.TopicCommand$AdminClientTopicService.describeTopic(TopicCommand.scala:301) at kafka.admin.TopicCommand$.main(TopicCommand.scala:68) at kafka.admin.TopicCommand.main(TopicCommand.scala)

Can anybody help me in solving this issue?

Upvotes: 1

Views: 10191

Answers (3)

Merve V
Merve V

Reputation: 11

I got the 'topic does not exist as expected error' when I tried to delete the topic and it said 'topic already exists' when I try to create the topic. Deleting the topic directory in kafka/data solved the problem for me. That way I didn't have to loose any data either. I didn't have to delete zookeeper data or kafka data.

Upvotes: 1

Mohammad Sunny
Mohammad Sunny

Reputation: 371

I have created 4 brokers and replication factor is 3 and I was checking for all brokers. Thats why it was not showing topic. When I checked it for 3 brokers, it gives me correct information and does not give any error.

Upvotes: 0

Suhas NM
Suhas NM

Reputation: 1080

Topic names are stored in zookeeper along with topic metadata, leader for each partition in the topic etc.

In your case it looks like zookeeper has this information, but maybe kafka data is either corrupt or deleted.

Stop kafka, zookeeper, remove your zookeeper data directory, kafka data directory and start both the services again.

Recreate your topic, it should work fine.

Upvotes: 2

Related Questions