errName:NoSuchTransaction errCode:251 - multithreaded - "Given transaction number 68 does not match any in-progress transactions"

If I use the same transaction across thread, even if I make sure no thread writes to the same collection, I will see my transaction auto-abort. There is no actual data collisions. If I do not re-use the transaction across threads I am fine.

The mongo logs blow showing the transactions and commands.

errName:NoSuchTransaction errCode:251

4.7.1 java sync driver
4.2 or 4.4 mongo replica set

2022-08-31T10:34:36.121+0000 D2 COMMAND  [conn34] run command import-export.$cmd { delete: "collection_a", ordered: true, $db: "import-export", $clusterTime: { clusterTime: Timestamp(1661942076, 10), signature: { hash: BinData(0, 0000000000000000000000000000000000000000), keyId: 0 } }, lsid: { id: UUID("b6d80dcf-de56-4716-a2f3-f4ff2590bf02") }, txnNumber: 68, startTransaction: true, autocommit: false }
2022-08-31T10:34:36.121+0000 D2 COMMAND  [conn48] run command import-export.$cmd { delete: "collection_b", ordered: true, $db: "import-export", $clusterTime: { clusterTime: Timestamp(1661942076, 10), signature: { hash: BinData(0, 0000000000000000000000000000000000000000), keyId: 0 } }, lsid: { id: UUID("b6d80dcf-de56-4716-a2f3-f4ff2590bf02") }, txnNumber: 68, autocommit: false }
2022-08-31T10:34:36.121+0000 D1 COMMAND  [conn48] assertion while executing command 'delete' on database 'import-export' with arguments '{ delete: "collection_b", ordered: true, $db: "import-export", $clusterTime: { clusterTime: Timestamp(1661942076, 10), signature: { hash: BinData(0, 0000000000000000000000000000000000000000), keyId: 0 } }, lsid: { id: UUID("b6d80dcf-de56-4716-a2f3-f4ff2590bf02") }, txnNumber: 68, autocommit: false }': NoSuchTransaction: Given transaction number 68 does not match any in-progress transactions. The active transaction number is 67
2022-08-31T10:34:36.121+0000 D4 TXN      [conn34] New transaction started with txnNumber: 68 on session with lsid b6d80dcf-de56-4716-a2f3-f4ff2590bf02
2022-08-31T10:34:36.121+0000 I  COMMAND  [conn48] command import-export.$cmd command: delete { delete: "collection_b", ordered: true, $db: "import-export", $clusterTime: { clusterTime: Timestamp(1661942076, 10), signature: { hash: BinData(0, 0000000000000000000000000000000000000000), keyId: 0 } }, lsid: { id: UUID("b6d80dcf-de56-4716-a2f3-f4ff2590bf02") }, txnNumber: 68, autocommit: false } numYields:0 ok:0 errMsg:"Given transaction number 68 does not match any in-progress transactions. The active transaction number is 67" errName:NoSuchTransaction errCode:251 reslen:377 locks:{ ReplicationStateTransition: { acquireCount: { w: 1 } } } protocol:op_msg 0ms
2022-08-31T10:34:36.122+0000 I  COMMAND  [conn34] command import-export.$cmd command: delete { delete: "collection_a", ordered: true, $db: "import-export", $clusterTime: { clusterTime: Timestamp(1661942076, 10), signature: { hash: BinData(0, 0000000000000000000000000000000000000000), keyId: 0 } }, lsid: { id: UUID("b6d80dcf-de56-4716-a2f3-f4ff2590bf02") }, txnNumber: 68, startTransaction: true, autocommit: false } numYields:0 reslen:230 locks:{} storage:{} protocol:op_msg 0ms
2022-08-31T10:34:36.132+0000 D2 COMMAND  [conn48] run command import-export.$cmd { update: "collection_a", ordered: true, $db: "import-export", $clusterTime: { clusterTime: Timestamp(1661942076, 10), signature: { hash: BinData(0, 0000000000000000000000000000000000000000), keyId: 0 } }, lsid: { id: UUID("b6d80dcf-de56-4716-a2f3-f4ff2590bf02") }, txnNumber: 68, autocommit: false }
2022-08-31T10:34:36.136+0000 I  COMMAND  [conn48] command import-export.$cmd command: update { update: "collection_a", ordered: true, $db: "import-export", $clusterTime: { clusterTime: Timestamp(1661942076, 10), signature: { hash: BinData(0, 0000000000000000000000000000000000000000), keyId: 0 } }, lsid: { id: UUID("b6d80dcf-de56-4716-a2f3-f4ff2590bf02") }, txnNumber: 68, autocommit: false } numYields:0 reslen:879 locks:{} storage:{} protocol:op_msg 3ms
2022-08-31T10:34:36.147+0000 D2 COMMAND  [conn48] run command import-export.$cmd { update: "collection_a", ordered: true, $db: "import-export", $clusterTime: { clusterTime: Timestamp(1661942076, 10), signature: { hash: BinData(0, 0000000000000000000000000000000000000000), keyId: 0 } }, lsid: { id: UUID("b6d80dcf-de56-4716-a2f3-f4ff2590bf02") }, txnNumber: 68, autocommit: false }
2022-08-31T10:34:36.149+0000 I  COMMAND  [conn48] command import-export.$cmd command: update { update: "collection_a", ordered: true, $db: "import-export", $clusterTime: { clusterTime: Timestamp(1661942076, 10), signature: { hash: BinData(0, 0000000000000000000000000000000000000000), keyId: 0 } }, lsid: { id: UUID("b6d80dcf-de56-4716-a2f3-f4ff2590bf02") }, txnNumber: 68, autocommit: false } numYields:0 reslen:879 locks:{} storage:{} protocol:op_msg 2ms
2022-08-31T10:34:36.159+0000 D2 COMMAND  [conn48] run command admin.$cmd { abortTransaction: 1, writeConcern: { w: "majority" }, $db: "admin", $clusterTime: { clusterTime: Timestamp(1661942076, 71), signature: { hash: BinData(0, 0000000000000000000000000000000000000000), keyId: 0 } }, lsid: { id: UUID("b6d80dcf-de56-4716-a2f3-f4ff2590bf02") }, txnNumber: 68, autocommit: false }
2022-08-31T10:34:36.159+0000 D3 TXN      [conn48] Received abortTransaction for transaction with txnNumber 68 on session { id: UUID("b6d80dcf-de56-4716-a2f3-f4ff2590bf02"), uid: BinData(0, E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855) }
2022-08-31T10:34:36.160+0000 I  TXN      [conn48] transaction parameters:{ lsid: { id: UUID("b6d80dcf-de56-4716-a2f3-f4ff2590bf02"), uid: BinData(0, E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855) }, txnNumber: 68, autocommit: false, readConcern: { level: "snapshot" } }, readTimestamp:Timestamp(0, 0), terminationCause:aborted timeActiveMicros:6160 timeInactiveMicros:31992 numYields:0 locks:{ ReplicationStateTransition: { acquireCount: { w: 2 } }, Global: { acquireCount: { w: 1 } }, Database: { acquireCount: { w: 1 } }, Collection: { acquireCount: { w: 1 } }, Mutex: { acquireCount: { r: 35 } } } storage:{} wasPrepared:0, 38ms
2022-08-31T10:34:36.165+0000 I  COMMAND  [conn48] command admin.$cmd command: abortTransaction { abortTransaction: 1, writeConcern: { w: "majority" }, $db: "admin", $clusterTime: { clusterTime: Timestamp(1661942076, 71), signature: { hash: BinData(0, 0000000000000000000000000000000000000000), keyId: 0 } }, lsid: { id: UUID("b6d80dcf-de56-4716-a2f3-f4ff2590bf02") }, txnNumber: 68, autocommit: false } numYields:0 reslen:163 locks:{ ReplicationStateTransition: { acquireCount: { w: 2 } }, Global: { acquireCount: { w: 1 } }, Database: { acquireCount: { w: 1 } }, Collection: { acquireCount: { w: 1 } }, Mutex: { acquireCount: { r: 35 } } } flowControl:{ acquireCount: 1, timeAcquiringMicros: 20 } storage:{} protocol:op_msg 5ms
1 Like