A leader epoch is a monotonically increasing version for a Kafka partition’s leadership. Each leader change increments it, allowing brokers to distinguish the current leader from a stale one. section 8.3.2
Rejecting a stale leader
Suppose Broker 3 leads Partition 2 and then becomes unreachable. Kafka elects another leader and increments the partition’s epoch from 0 to 1. If Broker 3 restarts believing it is still leader, its replication messages carry epoch 0 and are rejected because the current epoch is 1. section 8.3.2
$ cat ~/kafka/data/kafka1/\ products.prices.changelog.file-structure-0/leader-epoch-checkpoint 0 1 0 0
Inspect the leader-epoch-checkpoint file to see the initial epoch-and-offset entry. section 8.3.2
$ kafka-broker-stop.sh 3 $ cat ~/kafka/data/kafka1/\ products.prices.changelog.file-structure-0/leader-epoch-checkpoint 0 1 1 0
Compare the checkpoint after a broker stop to observe the epoch advancing from 0 to 1. section 8.3.2
