Issue with - Read Concern and Read Preferences

After shutting down two nodes when I run db.products.find().readPref(“primary”) as expected, error is generated BUT, I see two issues.

  1. Error message is “errmsg” : “not master and slaveOk=false”, The connected node is not master, that is fine but where as I have set slaveOk().
  2. When I execute following query I get result, WHY ?

Lecture Reads and Writes on a Replica Set explains about SlaveOK.
Also for final lab you actually don’t need to set anything regarding SlaveOK.
The question is which readPreference will allow you to read data - default behavior is probably assumed here. And for readPref(“primary”) you wrote answer in your post.

Thanks Malthion, I understand the question very well.

I found it quite puzzling when I have specified readPref(“primary”) while reading from database and there is no PRIMARY available, I should get an error that PRIMARY is not available.