-
Type: Bug
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: 2.4.3
-
Component/s: Connectivity
-
None
-
Environment:.NET 4.6.2, Windows 10 x64
When one of our databases fail over we sometimes get these exceptions:
MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server. ---> System.InvalidOperationException: Invalid BinaryConnection state transition from 2 to Failed. MongoDB.Driver.Core.Connections.BinaryConnection.ConnectionFailed(Exception exception) MongoDB.Driver.Core.Connections.BinaryConnection.<ReceiveBufferAsync>d__51.MoveNext() --- End of stack trace from previous location where exception was thrown --- !Async.Rethrow MongoDB.Driver.Core.Connections.BinaryConnection.<ReceiveBufferAsync>d__52.MoveNext() --- End of stack trace from previous location where exception was thrown --- !Async.Rethrow MongoDB.Driver.Core.Connections.BinaryConnection.<ReceiveMessageAsync>d__54.MoveNext() --- End of stack trace from previous location where exception was thrown --- !Async.Rethrow MongoDB.Driver.Core.WireProtocol.CommandWireProtocol`1.<ExecuteAsync>d__11.MoveNext() --- End of stack trace from previous location where exception was thrown --- !Async.Rethrow MongoDB.Driver.Core.Connections.ConnectionInitializer.<InitializeConnectionAsync>d__3.MoveNext() --- End of stack trace from previous location where exception was thrown --- !Async.Rethrow MongoDB.Driver.Core.Connections.BinaryConnection.<OpenHelperAsync>d__48.MoveNext() --- End of inner exception stack trace --- MongoDB.Driver.Core.Connections.BinaryConnection.<OpenHelperAsync>d__48.MoveNext() --- End of stack trace from previous location where exception was thrown --- !Async.Rethrow MongoDB.Driver.Core.Servers.Server.<GetChannelAsync>d__27.MoveNext() --- End of stack trace from previous location where exception was thrown --- !Async.Rethrow MongoDB.Driver.Core.Operations.BulkMixedWriteOperation.<ExecuteAsync>d__39.MoveNext() --- End of stack trace from previous location where exception was thrown --- !Async.Rethrow MongoDB.Driver.OperationExecutor.<ExecuteWriteOperationAsync>d__3`1.MoveNext() --- End of stack trace from previous location where exception was thrown --- !Async.Rethrow MongoDB.Driver.MongoCollectionImpl`1.<ExecuteWriteOperationAsync>d__62`1.MoveNext() --- End of stack trace from previous location where exception was thrown --- !Async.Rethrow MongoDB.Driver.MongoCollectionImpl`1.<BulkWriteAsync>d__22.MoveNext() --- End of stack trace from previous location where exception was thrown --- !Async.Rethrow MongoDB.Driver.MongoCollectionBase`1.<UpdateOneAsync>d__47.MoveNext() --- End of stack trace from previous location where exception was thrown ---
While the top-level exception (MongoConnectionException) looks good, the inner InvalidOperationException looks suspect to me.
P.S. !Async.Rethrow is part of our diagnostics' stack trace compression, it's equivalent to
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)