I am bit stuck in MongoDB while exporting my output to some other collection. Scenario : Actually, i want to query out my result to another collection which is successful in normal mongoDB( without Sharding). But, when i Shard that same DB , Mongo DB is giving me error code 13435 which is cannot read from replica set and gives me below error set : Error: command failed: { "ok" : 0, "errmsg" : "listIndexes failed: { ok: 0.0, errmsg: \"not master and slaveOk=false\", code: 13435, codeName: \"NotMasterNoSlaveOk\" }", "code" : 18631, "codeName" : "Location18631" } : aggregate failed : _getErrorWithCode@src/mongo/shell/utils.js:25:13 doassert@src/mongo/shell/assert.js:16:14 assert.commandWorked@src/mongo/shell/assert.js:370:5 DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1319:5 @(shell):1:1 Currently working on below versions of mongoDB : Version : 3.4.6 OS : Windows Server 2012 |
Hi
when i Shard that same DB , Mongo DB is giving me error code 13435 which is cannot read from replica set and gives me below error set
Could you elaborate on the steps you performed to arrive at this error message? If you’re connecting through mongos
, you shouldn’t see this message, even with an aggregation query with a $out
stage. This may be the result if you’re inadvertently connected to one of the secondaries in a shard instead of mongos
, since the error not master and slaveOk=false
is a general error if you’re trying to read from a secondary and has nothing to do with $out
.
The slaveOk()
setting on a secondary only allows the current connection to read from the connected secondary (see rs.slaveOk()). That is, this is not a global flag allowing any other connection to read from this secondary.
Best regards,
Kevin