[CSHARP-1014] Failing to connect to a replica set under load Created: 08/Jul/14  Updated: 04/Apr/15  Resolved: 04/Apr/15

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 1.9.1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Miki Mullor [X] Assignee: Unassigned
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 2012


Attachments: PNG File image-1.png     PNG File image.png    

 Description   

under some load (~100 concurrent threads), the driver throws the following exception:

"MESSAGE: Unable to connect to a member of the replica set matching the read preference Primary
STACKTRACE: at MongoDB.Driver.Internal.MultipleInstanceMongoServerProxy.ThrowConnectionException(ReadPreference readPreference)
at MongoDB.Driver.Internal.MultipleInstanceMongoServerProxy.Connect(TimeSpan timeout, ReadPreference readPreference)
at MongoDB.Driver.Internal.MultipleInstanceMongoServerProxy.ChooseServerInstance(ReadPreference readPreference)
at MongoDB.Driver.MongoServer.AcquireConnection(MongoDatabase database, ReadPreference readPreference)
at MongoDB.Driver.MongoCursorEnumerator`1.AcquireConnection()
at MongoDB.Driver.MongoCursorEnumerator`1.GetFirst()
at MongoDB.Driver.MongoCursorEnumerator`1.MoveNext()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
at MongoDB.Driver.MongoCollection.FindOneAs[TDocument](IMongoQuery query)
at MongoDB.Driver.MongoCollection`1.FindOne(IMongoQuery query)

if we remove the replica set from the connection, the problem goes away.

I saw another issue mentioning this problem where removing "disconnect" solves the issue. we don't use disconnect.

this is a blocking issue



 Comments   
Comment by Miki Mullor [ 08/Jul/14 ]

Instead of connecting to the replica set, we changed the connection
string to connect only to the primary node (removing read preferences
, only having one host asa target). Doing so works around the
issue.

Comment by Craig Wilson [ 08/Jul/14 ]

Could you explain what "if we remove the replica set from the connection, the problem goes away" means? I'm not sure what you are referring to.

Comment by Miki Mullor [X] [ 08/Jul/14 ]

It seems that when we attempt to acquire a connection there is a point in time where when Choosing the server instance to connect ( which should be a secondary as our read Preferences mode state) the list of connected instances retrieved from connectedInstance.GetSecondaries() have an invalid state.

they appear as disconnected and non of them is mark as IsSecondary.

Generated at Wed Feb 07 21:38:26 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.