MongoError: not master and slaveOk=false

2,234 views
Skip to first unread message

Natarajan P

unread,
Apr 7, 2016, 12:40:16 PM4/7/16
to mongodb-user

debug:  name=MongoError, message=not master and slaveOk=false, ok=0, errmsg=not master and slaveOk=false, code=13435, $ref=$["originalError"], rawStack=MongoError: not master and slaveOk=false

    at Function.MongoError.create (/OD-API/node_modules/sails-mongo/node_modules/mongodb/node_modules/mongodb-core/lib/error.js:31:11)

    at queryCallback (OD-API/node_modules/sails-mongo/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:281:36)

    at Callbacks.emit (OD-API/node_modules/sails-mongo/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:95:3)

    at null.messageHandler (OD-API/node_modules/sails-mongo/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:249:23)

    at Socket.<anonymous> (OD-API/node_modules/sails-mongo/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js:265:22)

    at Socket.emit (events.js:95:17)

    at Socket.<anonymous> (_stream_readable.js:765:14)

    at Socket.emit (events.js:92:17)

    at emitReadable_ (_stream_readable.js:427:10)

    at emitReadable (_stream_readable.js:423:5)

    at readableAddChunk (_stream_readable.js:166:9)

    at Socket.Readable.push (_stream_readable.js:128:10)

    at TCP.onread (net.js:529:21), details=Details:  MongoError: not master and slaveOk=false


rs0:PRIMARY> rs.status();

{

"set" : "rs0",

"date" : ISODate("2016-04-07T16:25:38.181Z"),

"myState" : 1,

"term" : NumberLong(2),

"heartbeatIntervalMillis" : NumberLong(2000),

"members" : [

{

"_id" : 0,

"name" : "Api01:27017",

"health" : 1,

"state" : 2,

"stateStr" : "SECONDARY",

"uptime" : 704,

"optime" : {

"ts" : Timestamp(1460045790, 3),

"t" : NumberLong(2)

},

"optimeDate" : ISODate("2016-04-07T16:16:30Z"),

"lastHeartbeat" : ISODate("2016-04-07T16:25:36.382Z"),

"lastHeartbeatRecv" : ISODate("2016-04-07T16:25:36.318Z"),

"pingMs" : NumberLong(0),

"syncingTo" : "Api02:27017",

"configVersion" : 3

},

{

"_id" : 1,

"name" : "Api02:27017",

"health" : 1,

"state" : 1,

"stateStr" : "PRIMARY",

"uptime" : 3156,

"optime" : {

"ts" : Timestamp(1460045790, 3),

"t" : NumberLong(2)

},

"optimeDate" : ISODate("2016-04-07T16:16:30Z"),

"electionTime" : Timestamp(1460043361, 1),

"electionDate" : ISODate("2016-04-07T15:36:01Z"),

"configVersion" : 3,

"self" : true

},

{

"_id" : 2,

"name" : "Api03:27017",

"health" : 1,

"state" : 2,

"stateStr" : "SECONDARY",

"uptime" : 724,

"optime" : {

"ts" : Timestamp(1460045790, 3),

"t" : NumberLong(2)

},

"optimeDate" : ISODate("2016-04-07T16:16:30Z"),

"lastHeartbeat" : ISODate("2016-04-07T16:25:36.348Z"),

"lastHeartbeatRecv" : ISODate("2016-04-07T16:25:36.202Z"),

"pingMs" : NumberLong(0),

"syncingTo" : "Api02:27017",

"configVersion" : 3

}

],

"ok" : 1

}


I tried executing rs.slaveOk() in the secondaries, but that too didn't work. Any help is much appreciated. Thanks

Natarajan P

unread,
Apr 7, 2016, 1:17:30 PM4/7/16
to mongodb-user
Here is what I've tried... I've executed rs.slaveOk() in secondary nodes, then the query works fine. But when I query from the application or reopen the shell, again I'm getting the same error. So with this I understood, that rs.slaveOk() is just for that particular mongo shell session. If so, what should I do to work in my application i.e., in all sessions
Reply all
Reply to author
Forward
0 new messages