[SERVER-10006] Secondary read pref with tag can end up selecting no nodes on retry Created: 24/Jun/13  Updated: 11/Jul/16  Resolved: 25/Jun/13

Status: Closed
Project: Core Server
Component/s: Internal Client
Affects Version/s: None
Fix Version/s: 2.5.1

Type: Bug Priority: Major - P3
Reporter: Randolph Tan Assignee: Randolph Tan
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File read_pref_cmd.txt    
Operating System: ALL
Participants:

 Description   

Example case:

2 node replica set:
primary tag:

{ dc: 'sf' }

secondary tag:

{ dc: 'ny' }

read pref setting:
mode: secondary
tags: [

{ dc: 'ny' }

]

If the secondary was down and the went up again, the replica set connection object will attempt to select nodes again (since the first try gave us nothing due to the node being down and marked as bad). However, the iterator for the tag was already moved on the first attempt and the retry would end up not checking the nodes because it already depleted the tags on the first attempt.



 Comments   
Comment by auto [ 25/Jun/13 ]

Author:

{u'username': u'renctan', u'name': u'Randolph Tan', u'email': u'randolph@10gen.com'}

Message: SERVER-10006 Secondary read pref with tag can end up selecting no nodes on retry

Added more descriptive comments for the tests.
Branch: master
https://github.com/mongodb/mongo/commit/fc8538ac9231a104d5858b25d24d6ca688c385ea

Comment by auto [ 25/Jun/13 ]

Author:

{u'username': u'renctan', u'name': u'Randolph Tan', u'email': u'randolph@10gen.com'}

Message: SERVER-10006 Secondary read pref with tag can end up selecting no nodes on retry

Reset the TagSet iterator to point to initial position before attempting to retry node selection logic.
Branch: master
https://github.com/mongodb/mongo/commit/6d27da0887b286c421751afc5e5cf573101c1eb8

Comment by Randolph Tan [ 24/Jun/13 ]

Note: this is also the cause for the buildbot failure (log attached). Here's the excerpt for the failure:

----
Testing mode: secondary, tag sets: [ { "tag" : "two" } ]
----
----
about to do: { "distinct" : "user", "key" : { "x" : 1 }, "query" : { "x" : 1 } }
----
Mon Jun 24 19:14:03.447 Socket closed remotely, no longer connected (idle 7 secs, remote host 10.29.160.141:31100)
 m31100| Mon Jun 24 19:14:03.448 [initandlisten] connection accepted from 10.29.160.141:54142 #21 (11 connections now open)
Mon Jun 24 19:14:03.449 Error: Failed to do query, no good nodes in test-rs0 at src/mongo/shell/collection.js:54
failed to load: /data/buildslaves/Linux_64bit/mongo/jstests/sharding/read_pref_cmd.js
 

Easiest way to reproduce is to modify the binary such that the ReplicaSetMonitorWatcher thread will never be created.

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