Skip to main content

should_abort_idle_transaction

Function should_abort_idle_transaction 

Source
pub fn should_abort_idle_transaction(
    state: IdleTransactionState,
    txn_timeout_ms: i32,
    start_ms: i64,
    now_ms: i64,
) -> bool
Expand description

Whether the idle reaper may abort one persisted transaction.

This is Kafka’s TransactionStateManager.timedOutTransactions: the transaction is ONGOING, it is not a KIP-939 two-phase-commit transaction (TransactionMetadata.isDistributedTwoPhaseCommitTxn, a timeout of Integer.MAX_VALUE), and txnStartTimestamp + txnTimeoutMs < now. The comparison is strict, so a transaction is reapable only once its timeout has passed, not when it is reached. Kafka evaluates the sum in a Java long; the kernel compares exactly, without overflow.

The decision is total over every persisted timeout. Kafka’s TransactionLog.read accepts any TransactionTimeoutMs, and InitProducerId refuses a timeout that is not positive (validateTransactionTimeoutMs), so a zero or negative timeout reaches the reaper only from a transaction-log record another writer produced. Kafka treats that timeout arithmetically, and so does this kernel.

A backwards clock never aborts a transaction with a nonnegative timeout, which is every timeout InitProducerId persists.