[SERVER-3309] Need a way to exclude a particular server from being read Created: 21/Jun/11  Updated: 18/Oct/11  Resolved: 29/Aug/11

Status: Closed
Project: Core Server
Component/s: Replication
Affects Version/s: 1.8.1
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Michael D. Norman Assignee: Scott Hernandez (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

As per recommended best practice, one of our secondary servers is in a different data center. However, when enabling slaveOK for a replication set, this server is sometimes read from, even though it's much slower than the secondaries in the same data center.

We have already set the priority to 0 so that this server never becomes master, but there does not appear to be a way to make that server unreadable by application code. I believe this is a core server issue since the configuration should be set in the replication set configuration and not in each client we want to use.



 Comments   
Comment by Grégoire Seux [ 18/Oct/11 ]

this issue can be solved using read preference SERVER-3358

Comment by Michael D. Norman [ 23/Jun/11 ]

Thank you Kristina, this appears to have cleared up the issue. I am able to see only the non-hidden DB instances from my client now.

Comment by Kristina Chodorow (Inactive) [ 22/Jun/11 ]

If you haven't restarted that member since making it hidden, please do so. There was a bug in 1.8 where certain reconfigs wouldn't be loaded by certain members until they are restarted.

Comment by Michael D. Norman [ 22/Jun/11 ]

They are identical

Comment by Scott Hernandez (Inactive) [ 22/Jun/11 ]

Can you run rs.conf() from each node? See if they match. I'm guess there is an error on one of the servers related to this.

Comment by Michael D. Norman [ 21/Jun/11 ]

Interestingly, when I call db.isMaster() from the secondary that is hidden, the following is returned:

pacman:SECONDARY> db.isMaster()
{
"setName" : "pacman",
"ismaster" : false,
"secondary" : true,
"hosts" : [
"prod-c0-pacmandb2",
"prod-c0-pacmandb1"
],
"primary" : "prod-c0-pacmandb1",
"passive" : true,
"hidden" : true,
"maxBsonObjectSize" : 16777216,
"ok" : 1
}

Comment by Michael D. Norman [ 21/Jun/11 ]

Java 2.6.3. It appears that db.isMaster() is returning the wrong results:

pacman:PRIMARY> db.isMaster()
{
"setName" : "pacman",
"ismaster" : true,
"secondary" : false,
"hosts" : [
"prod-c0-pacmandb1"
],
"passives" : [
"lab-c0-pacmandb1.lab",
"prod-c0-pacmandb2"
],
"maxBsonObjectSize" : 16777216,
"ok" : 1
}

Comment by Scott Hernandez (Inactive) [ 21/Jun/11 ]

What driver are you using? If you run db.isMaster() then hidden nodes are not shown and this is what drivers user to build the list of available secondaries for reading from.

Comment by Michael D. Norman [ 21/Jun/11 ]

pacman:SECONDARY> rs.conf()
{
"_id" : "pacman",
"version" : 2,
"members" : [

{ "_id" : 0, "host" : "prod-c0-pacmandb1" }

,

{ "_id" : 1, "host" : "prod-c0-pacmandb2" }

,

{ "_id" : 2, "host" : "lab-c0-pacmandb1.lab", "priority" : 0, "hidden" : true }

]
}

Comment by Michael D. Norman [ 21/Jun/11 ]

Though, to be honest, I was hoping it would!

Comment by Michael D. Norman [ 21/Jun/11 ]

It is marked as hidden. That does not take it out of the read pool of secondaries.

Comment by Scott Hernandez (Inactive) [ 21/Jun/11 ]

You will want to mark it hidden; that will take it out of the read pool of secondaries.

Generated at Thu Feb 08 03:02:42 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.