Expired Transactions failures should be reported more clearly in the driver error message
Long-running transactions may trigger an aborted transaction, but the cause is not clearly communicated by the driver exception message.
Failed: Command insert failed: Transaction 1 has been aborted..
Unhandled exception. MongoDB.Driver.MongoCommandException: Command insert failed: Transaction 1 has been aborted..
To reproduce, set a very low timeout:
replicaset:PRIMARY> db.adminCommand( { setParameter: 1, transactionLifetimeLimitSeconds: 1 } )
Then run a long running transaction from the C# driver.
The cause can be confirmed by checking the MongoDB log for a [abortExpiredTransaction]:
replicaset:PRIMARY> show log global
2020-07-31T03:59:49.196+0000 I COMMAND [abortExpiredTransactions] Aborting transaction with txnNumber 1 on session xxxxxx because it has been running for longer than 'transactionLifetimeLimitSeconds'
2020-07-31T03:59:49.196+0000 I TXN [abortExpiredTransactions] transaction parameters:{ lsid: { id: UUID("xxxxxx"), uid: BinData(0, xxxxxx) }, txnNumber: 1, autocommit: false, readConcern: { level: "snapshot" } }, readTimestamp:Timestamp(0, 0), terminationCause:aborted timeActiveMicros:51529 timeInactiveMicros:7004962 numYields:0 locks:{ ReplicationStateTransition: { acquireCount: { w: 3 } }, Global: { acquireCount: { w: 2 } }, Database: { acquireCount: { w: 2 } }, Collection: { acquireCount: { w: 2 } }, Mutex: { acquireCount: { r: 2 } } } storage:{} wasPrepared:0, 7056ms
It would be extremely useful for tracking down the cause if the driver exception message could communicate more detail as contained in the server log, e.g.,
"Aborting transaction with txnNumber 1 on session xxxxxx because it has been running for longer than 'transactionLifetimeLimitSeconds'"
![](https://secure.gravatar.com/avatar/d1fcf965b438dfbeaa22a607bd97035e?size=40&default=https%3A%2F%2Fassets.uvcdn.com%2Fpkg%2Fadmin%2Ficons%2Fuser_70-6bcf9e08938533adb9bac95c3e487cb2a6d4a32f890ca6fdc82e3072e0ea0368.png)