void triggerLeaderEpochBumpForIsrShrinkIfNeeded(PartitionChangeRecord record) {
        if (!(metadataVersion.isLeaderEpochBumpRequiredOnIsrShrink() || zkMigrationEnabled)) {
            // We only need to bump the leader epoch on an ISR shrink in two cases:
            //
            // 1. In older metadata versions before 3.6, there was a bug (KAFKA-15021) in the
            //    broker replica manager that required that the leader epoch be bumped whenever
            //    the ISR shrank. (This was never necessary for EXPANSIONS, only SHRINKS.)
            //
            // 2. During ZK migration, we bump the leader epoch during all ISR shrinks, in order
            // to maintain compatibility with migrating brokers that are still in ZK mode.
            //
            // If we're not in either case, we can exit here.
            return;
        }
        if (record.leader() != NO_LEADER_CHANGE) {
            // The leader is already changing, so there will already be a leader epoch bump.
            return;
        }
        if (record.isr() == null) {
            // The ISR is not changing.
            return;
        }
        if (!Replicas.contains(record.isr(), partition.isr)) {
            // If the new ISR 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 an ISR shrink.

Note that it's important to call this function only after we have set the ISR field in
the PartitionChangeRecord.
metadata/src/main/java/org/apache/kafka/controller/PartitionChangeBuilder.java