private void addProducerId(long producerId, ProducerStateEntry entry) {
        producers.put(producerId, entry);
        producerIdCount = producers.size();
    }
This method checks whether there is a late transaction in a thread safe manner.
storage/src/main/java/org/apache/kafka/storage/internals/log/ProducerStateManager.java