1
votes

Error: partition 0 does not have a leader. Skip getting offsets - but describe shows leader is present

I've got the same problem then Error: partition 0 does not have a leader. Skip getting offsets but --describe says that leader is present, do you have any solution please? Thanks

Kafka broker state-change log says:

[timestamp] ERROR [Controller id=**** epoch=**] Controller **** epoch ** failed to change state for partition ********* from OfflinePartition to OnlinePartition (state.change.logger)
kafka.common.StateChangeFailedException: Failed to elect leader for partition ********** under strategy OfflinePartitionLeaderElectionStrategy

Thanks again, total broker count is 4 partitioncount is 3 and replicationfactor is 4.

Note that consumer is not writing offsets on zookeeper

./kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list broker1:6667,broker2:6667 --topic topic1 --time -1

Error: partition 2 does not have a leader. Skip getting offsets 
Error: partition 1 does not have a leader. Skip getting offsets 
Error: partition 0 does not have a leader. Skip getting offsets

./kafka-topics.sh --describe --zookeeper zookeepernode01:2181 --topic topic1 

Topic: topic1 PartitionCount:3 ReplicationFactor:4 Configs: Topic: topic1

Partition: 0 Leader: 2 Replicas: 2,4,6,7 Isr: 2,4,6 Topic: topic1 
Partition: 1 Leader: 3 Replicas: 3,6,7,8 Isr: 3,7,8 Topic: topic1 
Partition: 2 Leader: 4 Replicas: 4,7,8,1001 Isr: 4,7 Topic: topic1
1

1 Answers

0
votes

Solved, the problem was that the infrastructure was changed from 4 to 3 brokers and the topics were the same. So there were some topics with non existing leader, they were also impossible to delete so the deletion was via zookeeper cli force removal:

How to Delete a topic in apache kafka