Closed zvictor closed 6 years ago
Topic:partition pairs that received LeaderNotAvailable
error during subscribe will be retried to subscribe on each _fetch
call. So thats exactly what you name as a second solution:
there needs to be a way to wait for a leader to be elected, and then be able to call subscribe again.
the problem
When running
SimpleConsumer.subscribe
in aLeaderNotAvailable
scenario, aUnknownTopicOrPartition
error is thrown:This can be reproduced (sometimes it works, sometimes it doesn't) running the code at https://github.com/Quadric/radiaction/tree/40d3433be9da803ab2c2207e51f4088bcb4ed069/examples/basic-example
It's important to have something done about it because such case is very hard to catch and debug. It took me days to find this error hidden inside
SimpleConsumer.client.topicMetadata
. Keep in mind that it is never guaranteed that the error will be there next time you run your code, given the nature of aLeaderNotAvailable
issue. That's how mytopicMetadata
looks sometimes (some other times it's just empty):the solutions
LeaderNotAvailable
error should be thrown as result of a failingsubscribe
due to the lack of a leadersubscribe
again.