Safemode detected an error 'not master'

280 views
Skip to first unread message

Grégoire Seux

unread,
Oct 3, 2011, 9:18:06 AM10/3/11
to mongodb...@googlegroups.com

Hello,

one of my applications crashed because the mongocsharp driver started throwing exception about not using the master.
It is likely to be related to the change of  master of one replicaset has changed during the process.
Is the driver supposed to handle this case or should I disconnect/reconnect to the server ?

2011-10-03 15:02:33.768 ; VERBOSE ; Problem processing message: { "ip" : "10.120.6.4", "pId" : 3804, "pType" : "Persister", "messageType" : "b", "partnerName" : "fixme", "t" : ISODate("2011-10-03T13:02:30.149Z") } ; Warning ;
MongoSafeModeException := Safemode detected an error 'not master'. (Response was { "singleShard" : "shard1/10.121.9.1:27021,10.120.9.1:27021", "err" : "not master", "code" : 10058, "n" : 0, "lastOp" : NumberLong("5659250514974474241"), "connectionId" : 2475, "ok" : 1.0 }).
   at MongoDB.Driver.Internal.MongoConnection.SendMessage(MongoRequestMessage message, SafeMode safeMode) in C:\source\mongo-csharp-driver\Driver\Internal\MongoConnection.cs:line 450
   at MongoDB.Driver.MongoCollection.InsertBatch(Type nominalType, IEnumerable documents, MongoInsertOptions options) in C:\source\mongo-csharp-driver\Driver\Core\MongoCollection.cs:line 1033
   at MongoDB.Driver.MongoCollection.Insert(Type nominalType, Object document, MongoInsertOptions options) in C:\source\mongo-csharp-driver\Driver\Core\MongoCollection.cs:line 885
   at MongoDB.Driver.MongoCollection.Insert(Type nominalType, Object document, SafeMode safeMode) in C:\source\mongo-csharp-driver\Driver\Core\MongoCollection.cs:line 902
   at MongoDB.Driver.MongoCollection.Insert(Type nominalType, Object document) in C:\source\mongo-csharp-driver\Driver\Core\MongoCollection.cs:line 867
   at MongoDB.Driver.MongoCollection.Insert[TNominalType](TNominalType document) in C:\source\mongo-csharp-driver\Driver\Core\MongoCollection.cs:line 826
   at CatalogImport.Monitor.doMonitorBsonMessage(BsonDocument bdoc) in C:\catalog-importGIT\tools\src\CatalogImport\Process\Monitor\Monitor.cs:line 111



Grégoire

Robert Stam

unread,
Oct 3, 2011, 11:25:57 AM10/3/11
to mongodb-csharp
The C# driver does handle failover with replica sets (but it has to
know that it is connected to a replica set).

What was your connection string? It should have included at least two
hostnames as the seed list.

One note: while the driver does handle failover, that does not mean
that you will not see *any* exceptions. The failover is not
instantaneous, and while an election is taking place there is no
master, and you will see exceptions until everything is back to
normal.

Grégoire Seux

unread,
Oct 3, 2011, 1:15:15 PM10/3/11
to mongodb...@googlegroups.com
On Mon, Oct 3, 2011 at 17:25, Robert Stam <rstam...@gmail.com> wrote:
The C# driver does handle failover with replica sets (but it has to
know that it is connected to a replica set).

What was your connection string? It should have included at least two
hostnames as the seed list.

The connection is done through a mongos.
 

One note: while the driver does handle failover, that does not mean
that you will not see *any* exceptions. The failover is not
instantaneous, and while an election is taking place there is no
master, and you will see exceptions until everything is back to
normal.

I understand, I have a applicative exception handling to automatically retry if something is wrong with mongo I had never seen this exception before (even if I have tested to kill a mongod during write load)  that's why I was curious.



--
Grégoire

Robert Stam

unread,
Oct 4, 2011, 8:44:06 AM10/4/11
to mongodb-csharp
If you are connecting through mongos then the C# driver is not
involved in deciding which replica set member to send queries to. The
driver simply sends all queries to mongos and mongos is responsible
for deciding which shard to send the query to.

Can you repost the question on the mongodb-user group, and phrase is
as a mongos question rather than a C# driver question. Include any
information you might have available, specially any log files from
mongos around the same time are the "not master" exception.

On Oct 3, 1:15 pm, Grégoire Seux <kamaradclim...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages