Hello again, sorry to dredge this up. I just realised that, when I said "it seems to work fine", I was not being completely accurate. My client code has a piece that catches mongo connection exceptions and retries the connection ten times before giving up. I noticed that it actually never succeeds the first time, and only on the second attempt does it get connected. It seems, oddly, when the connection string contains any of the following seed lists...
"mongodb://localTestingServer1/"
"mongodb://localTestingServer1,localTestingServer2,localTestingServer3/"
"mongodb://productionReplicasetServer1,productionReplicasetServer2,productionReplicasetServer3,localTestingServer1,localTestingServer2,localTestingServer3/"
...it works but when it contains...
"mongodb://productionReplicasetServer1,productionReplicasetServer2,productionReplicasetServer3,localTestingServer1/" (without local 2 or 3)
...I get the following exception the first time, then the second attempt works, presumably because by then the collection has already been modified and isn't being modified during enumeration.
System.InvalidOperationException, "Collection was modified; enumeration operation may not execute."
source: mscorlib
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
at System.Collections.Generic.List`1.Enumerator.MoveNext()
at MongoDB.Driver.MongoServer.VerifyInstances(List`1 instanceAddresses)
at MongoDB.Driver.MongoServerInstance.VerifyState(MongoConnection connection)
at MongoDB.Driver.MongoServerInstance.Connect(Boolean slaveOk)
at MongoDB.Driver.Internal.ReplicaSetConnector.ConnectWorkItem(Object argsObject)
Target site: Void ThrowInvalidOperationException(System.ExceptionResource)
For me, a suitable workaround obviously is to use the longest seed list, the one containing all three production and all three local testing servers. It does seem a bit like a bug to me, though.
Any thoughts?
Regards,
Mo