We're currently running all our MongoDB instances with version 2.0.5 of the MongoDB server with replica-sets.
Each server is hosted on a separate machine to cater for fail-over.
We are using version 1.3.0.4309 of the C# Driver and we're seeing the following error. It happens just after a network failure where one of the server instances takes over as primary in the replica-set:
Safemode detected an error 'not master'. (Response was { "err" : "not master", "code" : 10058, "n" : 0, "lastOp" : NumberLong(0), "connectionId" : 140567, "ok" : 1.0 }).
Here's the stack-trace of that error occurrence:
at MongoDB.Driver.Internal.MongoConnection.SendMessage(MongoRequestMessage message, SafeMode safeMode)
at MongoDB.Driver.MongoCollection.InsertBatch(Type nominalType, IEnumerable documents, MongoInsertOptions options)
at MongoDB.Driver.MongoCollection.Insert(Type nominalType, Object document, MongoInsertOptions options)
at MongoDB.Driver.MongoCollection.Insert(Type nominalType, Object document, SafeMode safeMode)
at MongoDB.Driver.MongoCollection.Insert(Type nominalType, Object document)
at MongoDB.Driver.MongoCollection.Insert[TNominalType](TNominalType document)
Our connection string has all three server names and ports as per the documentation.
It appears as if the MongoDB Connection in the C# driver is not checking that the one it knows to be primary is still the primary when doing a write operation. The only way we can recover from this is to restart the application pool the web application is running in, thereby forcing the next request to re-create the database connection object and then it knows which of the three server instance is now the primary again.
Is this perhaps a known issue with the version of the server software and C# driver we are using? We are planning on updating the code-base to use the latest version of the C# driver shortly.
Thanks in advance
Regards,
Demitri