File tree 2 files changed +5
-4
lines changed
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;
18
18
const isSharded = require ( './wireprotocol/shared' ) . isSharded ;
19
19
const maxWireVersion = require ( './utils' ) . maxWireVersion ;
20
20
21
- const MAX_FOR_TRANSACTIONS = 7 ;
21
+ const minWireVersionForShardedTransactions = 8 ;
22
22
23
23
function assertAlive ( session , callback ) {
24
24
if ( session . serverSession == null ) {
@@ -191,8 +191,9 @@ class ClientSession extends EventEmitter {
191
191
192
192
const topologyMaxWireVersion = maxWireVersion ( this . topology ) ;
193
193
if (
194
- isSharded ( this . topology ) ||
195
- ( topologyMaxWireVersion != null && topologyMaxWireVersion < MAX_FOR_TRANSACTIONS )
194
+ isSharded ( this . topology ) &&
195
+ ( topologyMaxWireVersion == null ||
196
+ topologyMaxWireVersion < minWireVersionForShardedTransactions )
196
197
) {
197
198
throw new MongoError ( 'Transactions are not supported on sharded clusters in MongoDB < 4.2.' ) ;
198
199
}
Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ describe('Transactions', function() {
71
71
72
72
describe ( 'startTransaction' , function ( ) {
73
73
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 ' } } ,
75
75
test : function ( done ) {
76
76
const configuration = this . configuration ;
77
77
const client = configuration . newClient ( configuration . writeConcernMax ( ) , { poolSize : 1 } ) ;
You can’t perform that action at this time.
0 commit comments