File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ const resolveClusterTime = require('./topologies/shared').resolveClusterTime;
1818const isSharded = require ( './wireprotocol/shared' ) . isSharded ;
1919const maxWireVersion = require ( './utils' ) . maxWireVersion ;
2020
21- const MAX_FOR_TRANSACTIONS = 7 ;
21+ const minWireVersionForShardedTransactions = 8 ;
2222
2323function assertAlive ( session , callback ) {
2424 if ( session . serverSession == null ) {
@@ -191,8 +191,9 @@ class ClientSession extends EventEmitter {
191191
192192 const topologyMaxWireVersion = maxWireVersion ( this . topology ) ;
193193 if (
194- isSharded ( this . topology ) ||
195- ( topologyMaxWireVersion != null && topologyMaxWireVersion < MAX_FOR_TRANSACTIONS )
194+ isSharded ( this . topology ) &&
195+ ( topologyMaxWireVersion == null ||
196+ topologyMaxWireVersion < minWireVersionForShardedTransactions )
196197 ) {
197198 throw new MongoError ( 'Transactions are not supported on sharded clusters in MongoDB < 4.2.' ) ;
198199 }
Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ describe('Transactions', function() {
7171
7272 describe ( 'startTransaction' , function ( ) {
7373 it ( 'should error if transactions are not supported' , {
74- metadata : { requires : { topology : [ 'sharded' ] , mongodb : '> 4.0.0 ' } } ,
74+ metadata : { requires : { topology : [ 'sharded' ] , mongodb : '4.0.x ' } } ,
7575 test : function ( done ) {
7676 const configuration = this . configuration ;
7777 const client = configuration . newClient ( configuration . writeConcernMax ( ) , { poolSize : 1 } ) ;
You can’t perform that action at this time.
0 commit comments