Details
-
Bug
-
Resolution: Done
-
Unknown
-
None
-
None
-
None
Description
the code is at https://github.com/byhu/springMongoTxTest.git
Test: TxTest.noSuchTransactionRecursive()
Here is a senariao the error occurs
- The first command starts a transaction.
- The second command fails when trying to participate the txn the first command started.
It appears the second command came too fast, the first one have not started the transaction yet.
Key fields.
lsid – is associated with a session. "lsid": {"id": {"$binary":
{"base64": "iH1VdrqKRv20ghDkmqkygg==", "subType": "04"}}},
txnNumber – is txn number of the session. "txnNumber": 4
request id – id of the command. request id 120
2021-07-13 15:22:33.477 DEBUG 10552 — [andler-executor] org.mongodb.driver.protocol.command : Sending command '{"update": "noSuchTransactionRecursive0", "ordered": true, "$db": "bhu", "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1626204153, "i": 60}}, "signature": {"hash": {"$binary": {"base64": "2MKqn5yo2V3q1dledt6XUNfzYyY=", "subType": "00"}}, "keyId": 6959228637484679170}}, "lsid": {"id": {"$binary":
{"base64": "iH1VdrqKRv20ghDkmqkygg==", "subType": "04"}}}, "txnNumber": 4, "startTransaction": true, "autocommit": false, "updates": [{"q":
{"_id": 30}, "u": {"_id": 30, "data": "a1 30", "_class": "bhu.tx.A"}, "upsert": true}]}' with request id 119 to database bhu on connection [connectionId\{localValue:19, serverValue:68504}] to server maas-sw-d6-u0055.nam.nsroot.net:37017
2021-07-13 15:22:33.479 DEBUG 10552 — [andler-executor] org.mongodb.driver.protocol.command : Sending command '{"update": "noSuchTransactionRecursive0", "ordered": true, "$db": "bhu", "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1626204153, "i": 60}}, "signature": {"hash": {"$binary": {"base64": "2MKqn5yo2V3q1dledt6XUNfzYyY=", "subType": "00"}}, "keyId": 6959228637484679170}}, "lsid": {"id": {"$binary":
{"base64": "iH1VdrqKRv20ghDkmqkygg==", "subType": "04"}}}, "txnNumber": 4, "autocommit": false, "updates": [{"q":
{"_id": 31}, "u": {"_id": 31, "data": "a1 31", "_class": "bhu.tx.A"}, "upsert": true}]}' with request id 120 to database bhu on connection [connectionId\{localValue:18, serverValue:68499}] to server maas-sw-d6-u0055.nam.nsroot.net:37017
2021-07-13 15:22:33.531 DEBUG 10552 — [andler-executor] org.mongodb.driver.protocol.command : Execution of command with request id 120 failed to complete successfully in 44.83 ms on connection [connectionId\{localValue:18, serverValue:68499}] to server maas-sw-d6-u0055.nam.nsroot.net:37017
com.mongodb.MongoCommandException: Command failed with error 251 (NoSuchTransaction): 'Given transaction number 4 does not match any in-progress transactions. The active transaction number is 3' on server maas-sw-d6-u0055.nam.nsroot.net:37017. The full response is {"errorLabels": ["TransientTransactionError"], "operationTime": {"$timestamp": {"t": 1626204153, "i": 41}}, "ok": 0.0, "errmsg": "Given transaction number 4 does not match any in-progress transactions. The active transaction number is 3", "code": 251, "codeName": "NoSuchTransaction", "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1626204153, "i": 60}}, "signature": {"hash": {"$binary": {"base64": "2MKqn5yo2V3q1dledt6XUNfzYyY=", "subType": "00"}}, "keyId": 6959228637484679170}}}
at com.mongodb.internal.connection.ProtocolHelper.getCommandFailureException(ProtocolHelper.java:175) ~[mongodb-driver-core-4.2.3.jar:na]