Motivation
When a topic transaction buffer times out while handling EndTxnOnPartition, the broker returns UnknownError. The transaction coordinator treats that response as non-retryable, which can leave a transaction in COMMITTING or ABORTING until the coordinator is reloaded.
Steps of issue occurring
- Client: commit transaction
- Broker-1(the owner of the transaction coordinator): received the request to commit transactions
- Update the status of the transaction to
Committing
- Sync status to Transaction Buffers
- Broker-2(the owner of the transaction buffer)
- throws
TimeoutException
- responds with an
UnknownError to Broker-1
- Broker-1: received
UnknownError
- Stops to retry; the status of the transaction remains
Committing
The issue can be solved by unloading the transaction coordinators: pulsar-admin topics unload persistent://pulsar/system/transaction_coordinator_assign-partition-x, because the pending txn will be retried when the Transaction Metadata Store is rebuilt.
Modifications
- Translate an otherwise-unmapped
TimeoutException from EndTxnOnPartition to ServerError.ServiceNotReady.
ServiceNotReady is decoded by the transaction-buffer client as a retryable ServiceNotReadyException, allowing the coordinator's existing retry logic to retry the end-transaction request.
- Add a transaction-buffer client test that triggers an asynchronous
endTxn timeout through a real broker/client request path and verifies the client receives ServiceNotReadyException.
Follow-up: monitoring and alerting
This PR focuses on the protocol-error classification. A follow-up should add a coordinator-level pulsar_txn_oldest_state_age_seconds gauge, labeled by cluster, broker, coordinator ID, and non-terminal state (initially COMMITTING and ABORTING). It should not include transaction ID or topic labels, to avoid unbounded cardinality.
A warning alert can trigger when pulsar_txn_oldest_state_age_seconds{state=~"COMMITTING|ABORTING"} > 600 persists, to identify coordinators that are no longer making end-transaction progress.
Tests
./gradlew :pulsar-broker:test --tests org.apache.pulsar.broker.transaction.buffer.TransactionBufferClientTest.testCommitOnTopicTimeoutReturnsServiceNotReady -PtestRetryCount=0
./gradlew :pulsar-broker:checkstyleTest