0

I have a replica set with two secondaries. These secondaries are not meant for failover, they are backups of the master, one of them with a delay of 1 day. I've set them both to hidden=true and priority=0

rs.conf().members on the master yields

[
        {
                "_id" : 0,
                "host" : "localhost:4000",
                "arbiterOnly" : false,
                "buildIndexes" : true,
                "hidden" : false,
                "priority" : 1,
                "tags" : {

                },
                "slaveDelay" : NumberLong(0),
                "votes" : 1
        },
        {
                "_id" : 1,
                "host" : "localhost:4001",
                "arbiterOnly" : false,
                "buildIndexes" : true,
                "hidden" : true,
                "priority" : 0,
                "tags" : {

                },
                "slaveDelay" : NumberLong(0),
                "votes" : 1
        },
        {
                "_id" : 2,
                "host" : "localhost:4002",
                "arbiterOnly" : false,
                "buildIndexes" : true,
                "hidden" : true,
                "priority" : 0,
                "tags" : {

                },
                "slaveDelay" : NumberLong(86400),
                "votes" : 1
        }
]

I want to check their content, mainly to issue .count() queries.

Is it safe to call rs.slaveOk() on those secondaries?

Daniel F
  • 13,684
  • 11
  • 87
  • 116
  • It's fine to run count on a hidden secondary. What sort of safety issues are you envisioning? A more dangerous scenario is running all members of your replica set on the same server, as appears to be the case in your current output (although I assume this is a test deployment on localhost). – Stennie Jan 15 '18 at 22:26
  • @Stennie Thanks. My concern arose from a comment in https://stackoverflow.com/a/17155038/277267 but I was aware that I'm not modifying that data. I thought it would put the database in a different state forever. As it turns out that this is a per-connection setting, I'm no longer worrying. Regarding your localhost concern: https://dba.stackexchange.com/questions/173911/mongodb-replica-set-over-ssh-tunnels – Daniel F Jan 15 '18 at 22:33

0 Answers0