void triggerLeaderEpochBumpForReplicaReassignmentIfNeeded(PartitionChangeRecord record) {
        if (record.leader() != NO_LEADER_CHANGE) {
            // The leader is already changing, so there will already be a leader epoch bump.
            return;
        }
        if (!Replicas.contains(targetReplicas, partition.replicas)) {
            // If the new replica list does not contain all the brokers that the old one did,
            // ensure that there will be a leader epoch bump by setting the leader field.
            record.setLeader(partition.leader);
        }
    }
Trigger a leader epoch bump if one is needed because of replica reassignment.

Note that if the leader epoch increases, the partition epoch will always increase as well; there is no
case where the partition epoch increases more slowly than the leader epoch.
metadata/src/main/java/org/apache/kafka/controller/PartitionChangeBuilder.java