File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
src/MongoDB.Driver.Core/Core/Bindings
tests/MongoDB.Driver.Core.Tests/Core/Bindings Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -467,7 +467,13 @@ private void EnsureTransactionsAreSupported()
467
467
468
468
foreach ( var connectedDataBearingServer in connectedDataBearingServers )
469
469
{
470
- if ( connectedDataBearingServer . Type == ServerType . ShardRouter )
470
+ var serverType = connectedDataBearingServer . Type ;
471
+
472
+ if ( serverType == ServerType . Standalone || serverType == ServerType . Unknown )
473
+ {
474
+ throw new NotSupportedException ( "Transactions are supported only in sharded cluster of replica set deployments." ) ;
475
+ }
476
+ else if ( serverType == ServerType . ShardRouter )
471
477
{
472
478
Feature . ShardedTransactions . ThrowIfNotSupported ( connectedDataBearingServer . Version ) ;
473
479
}
Original file line number Diff line number Diff line change @@ -325,6 +325,8 @@ public void EnsureTransactionsAreSupported_should_throw_when_there_are_no_connec
325
325
}
326
326
327
327
[ Theory ]
328
+ [ InlineData ( "NT" ) ]
329
+ [ InlineData ( "UT" ) ]
328
330
[ InlineData ( "PN" ) ]
329
331
[ InlineData ( "PN,ST" ) ]
330
332
[ InlineData ( "PT,SN" ) ]
@@ -358,7 +360,11 @@ public void EnsureTransactionsAreSupported_should_throw_when_any_connected_data_
358
360
var exception = Record . Exception ( ( ) => subject . EnsureTransactionsAreSupported ( ) ) ;
359
361
360
362
var e = exception . Should ( ) . BeOfType < NotSupportedException > ( ) . Subject ;
361
- e . Message . Should ( ) . Contain ( $ "does not support the { unsupportedFeatureName } feature.") ;
363
+ e . Message . Should ( ) . Match < string > (
364
+ s => s . Contains ( $ "does not support the { unsupportedFeatureName } feature.") ||
365
+ s . Contains ( "Transactions are supported only in sharded cluster of replica set deployments." ) ||
366
+ s . Contains ( "StartTransaction cannot determine if transactions are supported because there are no connected servers." )
367
+ ) ;
362
368
}
363
369
364
370
// private methods
@@ -446,6 +452,7 @@ private ServerType MapServerTypeCode(char code)
446
452
switch ( code )
447
453
{
448
454
case 'A' : return ServerType . ReplicaSetArbiter ;
455
+ case 'N' : return ServerType . Standalone ;
449
456
case 'P' : return ServerType . ReplicaSetPrimary ;
450
457
case 'R' : return ServerType . ShardRouter ;
451
458
case 'S' : return ServerType . ReplicaSetSecondary ;
You can’t perform that action at this time.
0 commit comments