-
Type: Improvement
-
Resolution: Works as Designed
-
Priority: Unknown
-
None
-
Affects Version/s: 4.5.0
-
Component/s: Reactive Streams, Transaction Management
-
None
I'll attach an example reproduction case, but in my case when using a session for a transaction the logs show the following:
[main] INFO ClientSessionTest - started transaction:: txn: 166 [main] INFO ClientSessionTest - committed transaction:: txn: 166 [main] INFO ClientSessionTest - started transaction:: txn: 167 [Thread-10] INFO org.mongodb.driver.connection - Opened connection [connectionId{localValue:28, serverValue:320}] to localhost:27018 [Thread-21] WARN LatchedSubscriber - Publisher failed com.mongodb.MongoCommandException: Command failed with error 251 (NoSuchTransaction): 'Given transaction number 167 does not match any in-progress transactions. The active transaction number is 166' on server localhost:27018. The full response is {"errorLabels": ["TransientTransactionError"], "ok": 0.0, "errmsg": "Given transaction number 167 does not match any in-progress transactions. The active transaction number is 166", "code": 251, "codeName": "NoSuchTransaction", "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1646911501, "i": 430}}, "signature": {"hash": {"$binary": {"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=", "subType": "00"}}, "keyId": 0}}, "operationTime": {"$timestamp": {"t": 1646911501, "i": 421}}}
So in the above case. Transaction 166, started and was committed before startTransaction 167 started but using the session with txn 167 failed.
Steps to reproduce the issue:
- unarchive mongodb-session.problem.tgz
- mvn clean package
- java -jar target/mongodb-session-problem-1.0-SNAPSHOT-jar-with-dependencies.jar &> logs.txt
This example should also be reproducible using intellij.
There is a sync example as well (change the pom.xml main class) which does not have this issue.