public void check(@NotNull Set<Long> partitionIds, long currentTimeMs)
            throws CommitRateExceededException, CommitFailedException {
        Preconditions.checkNotNull(partitionIds, "partitionIds is null");
        // Does not limit the commit rate of compaction transactions
        if (transactionState.getSourceType() == TransactionState.LoadJobSourceType.LAKE_COMPACTION) {
            return;
        }

        updateWriteDuration(transactionState);
        setAllowCommitTimeOnce(partitionIds);

        long txnId = transactionState.getTransactionId();
        long abortTime = transactionState.getPrepareTime() + transactionState.getTimeoutMs();

        if (transactionState.getAllowCommitTimeMs() >= abortTime) {
            throw new CommitFailedException("Txn " + txnId + " timed out due to ingestion slowdown", txnId);
        }
        if (transactionState.getAllowCommitTimeMs() > currentTimeMs) {
            LOG.info("delay commit of txn {} for {}ms, write took {}ms", transactionState.getTransactionId(),
                    transactionState.getAllowCommitTimeMs() - currentTimeMs,
                    transactionState.getWriteDurationMs());
            throw new CommitRateExceededException(txnId, transactionState.getAllowCommitTimeMs());
        }
        long upperBound = compactionScoreUpperBound();
        if (upperBound > 0 && anyCompactionScoreExceedsUpperBound(partitionIds, upperBound)) {
            throw new CommitRateExceededException(txnId, currentTimeMs + 1000/* delay 1s */);
        }
    }
@Test
    public void testPartitionHasNoStatistics() throws CommitRateExceededException {
        long partitionId = 54321;
        Set<Long> partitions = new HashSet<>(Collections.singletonList(partitionId));

        long currentTimeMs = System.currentTimeMillis();
        transactionState.setPrepareTime(currentTimeMs - 100);
        transactionState.setWriteEndTimeMs(currentTimeMs);

        Assert.assertTrue(ratio > 0.01);
        Assert.assertTrue(threshold > 0);

        limiter.check(partitions, currentTimeMs);
        Assert.assertEquals(transactionState.getWriteEndTimeMs(), transactionState.getAllowCommitTimeMs());
    }