[JAVA-3240] No exception thrown when attempting sharded transactions on 4.2 Created: 19/Mar/19  Updated: 28/Oct/23  Resolved: 03/Apr/19

Status: Closed
Project: Java Driver
Component/s: Transaction Management
Affects Version/s: None
Fix Version/s: 3.10.2

Type: Bug Priority: Major - P3
Reporter: Jeffrey Yemin Assignee: Jeffrey Yemin
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by DRIVERS-624 Ensure 4.0 drivers return an error wh... Implementing
Related
related to PYTHON-1781 PyMongo 3.7 does not raise an error w... Closed
Epic Link: JVM 4.2 Support

 Description   

The 4.0 transaction spec says:

startTransaction SHOULD report an error if the driver can detect that transactions are not supported by the deployment. A deployment does not support transactions when the deployment does not support sessions, or maxWireVersion < 7, or the topology type is Sharded

https://github.com/mongodb/specifications/blob/cf7248b2574b1a5397a6e18362acfe66f2b55a43/source/transactions/transactions.rst#starttransaction

However, the Java driver never implemented this check. When 3.10.1 runs a transaction against MongoDB 4.2, it will get an error like this on the first command that goes to a new mongos:

{
  'ok': 0.0,
  'errmsg': 'cannot continue txnId -1 for session ... with txnId 1',
  'code': 251,
  'codeName': 'NoSuchTransaction',
  'errorLabels': ['TransientTransactionError']
}



 Comments   
Comment by Githook User [ 03/Apr/19 ]

Author:

{'name': 'Jeff Yemin', 'username': 'jyemin', 'email': 'jeff.yemin@10gen.com'}

Message: Throw MongoClientException for sharded cluster transactions

This version of the driver does not support sharded cluster
transactions, so should throw a MongoClientException it an application
attempts it.

JAVA-3240
Branch: 3.10.x
https://github.com/mongodb/mongo-java-driver/commit/89ffdb5b6692bb8039e074ce0f76da08ef39d7e3

Generated at Thu Feb 08 08:59:07 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.