0
votes

I have a mongo setup as a P-S-S architecture, 1 the connection string looks like mongodb://mongo1,mongo2,mongo3/db1?replicaSet=rs .

One of my applications (nodejs) every once is a while will attempt to read and get a not master and slaveOk=false error. I expected the this to only read from the primary, given the default read concern.

Question: Why would the driver direct the read to a secondary?

1

1 Answers

1
votes

well - to get a - not master and slaveOk=false error - when set to read primary - would be what correctly occurs when the primary is not available. So maybe your real question is why is the primary not available? …..see what I mean? … in a replica set there should always be primary but who knows - there must be a transitory moment when the election occurs during failover....you might want to check the logs to see how often the primary is going down......now if you do not want to get this error change the read preference to Primary Preferred.