public synchronized void maybeUpdateProducerIdAndEpoch(TopicPartition topicPartition) {
        if (hasFatalError()) {
            log.debug("Ignoring producer ID and epoch update request since the producer is in fatal error state");
            return;
        }

        if (hasStaleProducerIdAndEpoch(topicPartition) && !hasInflightBatches(topicPartition)) {
            // If the batch was on a different ID and/or epoch (due to an epoch bump) and all its in-flight batches
            // have completed, reset the partition sequence so that the next batch (with the new epoch) starts from 0
            txnPartitionMap.startSequencesAtBeginning(topicPartition, this.producerIdAndEpoch);
            log.debug("ProducerId of partition {} set to {} with epoch {}. Reinitialize sequence at beginning.",
                      topicPartition, producerIdAndEpoch.producerId, producerIdAndEpoch.epoch);
        }
    }
Get the current producer id and epoch without blocking. Callers must use {@link ProducerIdAndEpoch#isValid()} to
verify that the result is valid.

@return the current ProducerIdAndEpoch.
clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionManager.java