[JAVA-812] setting slaveOK() does not result in a secondary read preference through mongos Created: 23/Apr/13 Updated: 31/Mar/15 Resolved: 22/Aug/13 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Cluster Management, Connection Management |
| Affects Version/s: | 2.11.1 |
| Fix Version/s: | 2.11.3, 3.0.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Andre de Frere | Assignee: | Jeffrey Yemin |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||
| Description |
|
Although slaveOk() is deprecated, if it is in use the expectation is it should behave the same as setting ReadPreference.secondaryPreferred(); Instead the queries are seen with { $readPreference: { mode: "primary" }} explicitly set when going through a mongos Under 2.6 the following java sample will correctly result in a query to a Secondary. The same code in 2.7 or above will result with the primary $readPreference set.
Looking at the highest verbosity logs (or capturing the query in another way) under 2.11.1 will show the query executed with { $readPreference: { mode: "primary" }} on both the mongos and the Primary node:
|
| Comments |
| Comment by Jeffrey Yemin [ 31/Mar/15 ] |
|
Closing all resolved 3.0.0 issues, as 3.0.0 has been tagged and released. |
| Comment by auto [ 12/Sep/13 ] |
|
Author: {u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}Message: |
| Comment by auto [ 22/Aug/13 ] |
|
Author: {u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}Message: |
| Comment by Jeffrey Yemin [ 24/Apr/13 ] |
|
The driver is setting both the slaveok bit in query options and {$readPreference : {"mode" : "primary}}, and as of mongos 2.2, the read preference wins and queries are routed to shard primaries. |