There is no leader for this topic-partition as we are in the middle of a leadership election
See original GitHub issueDescribe the bug With a kafka started with KAFKA_AUTO_CREATE_TOPICS_ENABLE, I get “There is no leader for this topic-partition as we are in the middle of a leadership election” errors when sending a message on a non existing topic.
Also described here
I use the admin tool to create non existing topic as a workaround:
await this.admin.connect()
const existingTopics = await this.admin.listTopics()
if (!existingTopics.some((topic) => topic === topics.create.event)) {
await this.admin.createTopics({
waitForLeaders: true,
topics: [
{ topic: topics.create.event }
]
})
}
await this.admin.disconnect()
But since I have auto create topics on it does not really make sense to create them upfront.
To Reproduce Start a kafka with no topics send a message with a non-existing topic, and get the error.
Expected behavior No error produced
Observed behavior The error is produced
Feature request Make producer.send() waitForLeaders like admin.createTopics() does
Environment:
- KafkaJS version 1.15.0
- Kafka version latest
- NodeJS version 15.5.1
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top Results From Across the Web
There is no leader for this topic-partition as we are in ... - GitHub
I'm using kafka with KafkaJS. When I do docker-compose up everything works fine. But if I change any of the kafka configs or...
Read more >Kafka There is no leader for this topic-partition as we are in the ...
i made the test again but still the same issue appear, there is no leader for this topic partition as we are in...
Read more >In the middle of a leadership election, there is currently no ...
Hi, I'm running three kafka brokers. I receive the following when using the producer panic: kafka server: In the middle of a leadership...
Read more >Kafka Topic Configuration: Unclean Leader Election - Conduktor
When the leader for a partition is no longer available, one of the in-sync replicas (ISR) will be chosen as the new leader....
Read more >Kafka There is no leader for this topic-partition as we are in the ...
Kafka There is no leader for this topic-partition as we are in the middle of a leadership election. Answer a question just starting...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Can the log be turned off? If everything is ok, then there shouldn’t be error messages in the log.
This message got me chasing problems for quite some time, but indeed even though the message is printed, the message is sent as expected.