Documentation

gitHub

MongoDB error not master and slaveOk=false

If you get an error "not master and slaveOk=false" when connecting to a MongoDB instance, on a secondary member (for example, a replica set connection using a read preference of secondary or secondaryPreferred), you first need to run rs.slaveOk() to be able to freely run Hackolade's reverse-engineering. This is because, by default, MongoDB does not permit read operations from non-master (i.e., slave or secondary) instances.

In MongoDB, reads to a primary have strict consistency, meaning that the data it provides reflects the latest writes at all times. Reads from secondaries in MongoDB have eventual consistency, meaning that changes to the system can propagate gradually and readable members are not required to reflect the latest writes at all times.

By calling rs.slaveOk() you are indicating to the system that you acknowledge that reads will be eventually consistent and wish to be able to run reverse-engineering from the secondary anyway.