-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 1.2
-
Component/s: None
-
None
Initial connection to a replica set leads to deadlock. The source of the deadlock is the change of the locking protocol in response to the CSHARP-268.
While connecting to a replica set of 3 machines (primary, secondary, arbiter) first time, a deadlock occurs with the following four threads of interest:
1. actual connection thread:
MongoDB.Driver.dll!MongoDB.Driver.Internal.BlockingQueue<System.__Canon>.Dequeue(System.TimeSpan timeout) Line 53 C#
MongoDB.Driver.dll!MongoDB.Driver.Internal.ReplicaSetConnector.Connect(System.TimeSpan timeout) Line 61 + 0xc bytes C#
MongoDB.Driver.dll!MongoDB.Driver.MongoServer.Connect(System.TimeSpan timeout) Line 457 C#
MongoDB.Driver.dll!MongoDB.Driver.MongoServer.GetServerInstance(bool slaveOk) Line 976 + 0xd bytes C#
MongoDB.Driver.dll!MongoDB.Driver.MongoServer.AcquireConnection(MongoDB.Driver.MongoDatabase database, bool slaveOk) Line 920 C#
MongoDB.Driver.dll!MongoDB.Driver.MongoCursorEnumerator<System.__Canon>.AcquireConnection() Line 184 + 0x42 bytes C#
MongoDB.Driver.dll!MongoDB.Driver.MongoCursorEnumerator<MongoDB.Bson.BsonDocument>.GetFirst() Line 194 + 0xc bytes C#
MongoDB.Driver.dll!MongoDB.Driver.MongoCursorEnumerator<System.__Canon>.MoveNext() Line 126 + 0x8 bytes C#
MongoDB.Driver.dll!MongoDB.Driver.MongoDatabase.GetCollectionNames() Line 649 + 0xdc bytes C#
MongoDB.Driver.dll!MongoDB.Driver.MongoDatabase.CollectionExists(string collectionName) Line 290 + 0xa bytes C#
2,3,4: instance connection threads:
[In a sleep, wait, or join]
MongoDB.Driver.dll!MongoDB.Driver.MongoServer.InstanceStateChanged(object sender, object args) Line 1037 C#
MongoDB.Driver.dll!MongoDB.Driver.MongoServerInstance.State.set(MongoDB.Driver.MongoServerState value) Line 174 + 0xd bytes C#
MongoDB.Driver.dll!MongoDB.Driver.MongoServerInstance.Connect(bool slaveOk) Line 216 + 0x11 bytes C#
MongoDB.Driver.dll!MongoDB.Driver.Internal.ReplicaSetConnector.ConnectWorkItem(object argsObject) Line 100 + 0xd bytes C#
mscorlib.dll!System.Threading.ExecutionContext.runTryCode(object userData) + 0x178 bytes
[Native to Managed Transition]
[Managed to Native Transition]
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool ignoreSyncCtx) + 0xa1 bytes
mscorlib.dll!System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() + 0x69 bytes
mscorlib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch() + 0x193 bytes
mscorlib.dll!System.Threading._ThreadPoolWaitCallback.PerformWaitCallback() + 0x35 bytes
Both kinds of threads have the lock on serverLock (MongoServer.Connect for 1st kind and MongoServer.InstanceStateChanged for 2nd kind) and the first thread appears to wait second ones to connect, which they can't do, because they're blocked on the lock.
- is related to
-
CSHARP-268 NullReferenceException on lost primary
- Closed