[SERVER-3462] slaveOk queries don't distribute to all secondaries when using a mongos Created: 21/Jul/11  Updated: 12/Jul/16  Resolved: 27/Jul/11

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 1.8.2, 1.9.0
Fix Version/s: 1.8.3, 1.9.2

Type: Bug Priority: Minor - P4
Reporter: Scott Hernandez (Inactive) Assignee: Spencer Brody (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

When adding a hidden replica one of the secondaries is no longer sent queries when slaveOk is used. Reproduced with 4 replicas (one hidden/prio=0) + 1 arbiter.



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

Updated fix version because it was backported to 1.8.3:

git tag --contains bb85c0204c705186ca1bd67c6f39e1920ee5711d
r1.8.3
r1.8.3-rc1

Comment by auto [ 07/Aug/11 ]

Author:

{u'login': u'erh', u'name': u'Eliot Horowitz', u'email': u'eliot@10gen.com'}

Message: backport of SERVER-3462
Branch: v1.8
https://github.com/mongodb/mongo/commit/bb85c0204c705186ca1bd67c6f39e1920ee5711d

Comment by auto [ 06/Aug/11 ]

Author:

{u'login': u'erh', u'name': u'Eliot Horowitz', u'email': u'eliot@10gen.com'}

Message: better slave handling for SERVER-3462
Branch: master
https://github.com/mongodb/mongo/commit/41f43db6e267a1007800a324cc9e5735fc37a06c

Comment by auto [ 06/Aug/11 ]

Author:

{u'login': u'erh', u'name': u'Eliot Horowitz', u'email': u'eliot@10gen.com'}

Message: finish SERVER-3462
Branch: master
https://github.com/mongodb/mongo/commit/7355a811bac3b021bd066a5a4ddcb4b47cb721a3

Comment by Spencer Brody (Inactive) [ 01/Aug/11 ]

This fix is being considered for the 1.8.3 release, but we don't decide 100% what's going into a minor stability improvement release like 1.8.3 until the dev release goes out and gets some stability testing.

Comment by Nathan Acuff [ 30/Jul/11 ]

Any chance of a backport to 1.8.X?

Comment by auto [ 26/Jul/11 ]

Author:

{u'login': u'stbrody', u'name': u'Spencer T Brody', u'email': u'spencer@10gen.com'}

Message: Make doing slaveOk reads use all secondaries - SERVER-3462
Branch: master
https://github.com/mongodb/mongo/commit/39032a0f977ca4360fa9077dd24b5e03269db993

Comment by Spencer Brody (Inactive) [ 22/Jul/11 ]

Fix ready. You can see it at https://github.com/stbrody/mongo/commit/55838b9984c6301a3b465761ec5b4428bccbc373.
Waiting for 1.9.1 to go out before I push it.

Comment by Spencer Brody (Inactive) [ 22/Jul/11 ]

Also, I don't think having a hidden node is necessary to reproduce, I think the actual cause is whether you have an odd or even number of visible secondaries. If you have an odd number of secondaries, even if you're skipping every other node in the rotation, you'll still hit every node. If you have an even number of secondaries, however, skipping every other node causes you to only use 50% of the available secondaries.

Comment by Spencer Brody (Inactive) [ 22/Jul/11 ]

I think I found the source of the bug. In DBClientReplicaSet::checkSlave, it gets a connection to a slave, which might be an existing connection or might be a new connection. If it's an existing connection that was made invalid it gets a new connection. The bug is that it also gets another new connection when the first connection was a new connection to begin with. This causes it to skip over a slave in some cases. The fix is to change the code to only get the second connection when the first one was invalid.

Patch will be coming as soon as I have a regression test.

Comment by Eliot Horowitz (Inactive) [ 22/Jul/11 ]

Is there a script that reproduces?
Ideally a JS test.

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