[CDRIVER-1885] Hinted cursors should not set slaveOk bit for primary servers Created: 25/Oct/16 Updated: 02/Nov/16 Resolved: 02/Nov/16 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | libmongoc |
| Affects Version/s: | 1.4.2 |
| Fix Version/s: | 1.5.0 |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Jeremy Mikola | Assignee: | A. Jesse Jiryu Davis |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Description |
|
From the server selection spec section on Topology types: ReplicaSetWithPrimary or ReplicaSetNoPrimary: Read Operations:
As mentioned in the code review for Fixing this means that users will now receive a "not master" error if libmongoc thinks the node is a primary, omits the slaveOk bit, and the server is actually in a non-primary state. That said, how would a host transition from a primary to non-primary state without dropping its connections? Would this "not master" edge case even happen in practice, or is this just a theoretical? As an aside, I'm not familiar with the reasoning behind the spec's rule on not setting slaveOK for primary queries. Apart from mongos, which infers a read preference behavior based on slaveOK, the bit seems like an implementation detail. Would it be worthwhile to revise the spec to simply allow drivers to specify slaveOK as they wish for non-mongos connections? |
| Comments |
| Comment by Githook User [ 02/Nov/16 ] |
|
Author: {u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}Message: |
| Comment by A. Jesse Jiryu Davis [ 31/Oct/16 ] |
|
We should do this. Hannes pointed out that for PHP to conform to Server Selection Spec, cursors have to act this way. |
| Comment by A. Jesse Jiryu Davis [ 25/Oct/16 ] |
|
Single threaded: Primary steps down & closes connections, we wait socketCheckIntervalMS (default 5 sec), we try a query. We check the socket, it's closed, we reopen and query the server we thought was primary, without noticing it's a secondary. Currently, we make sure we raise an error in this case by not setting slaveOk, so the stepped-down server complains "not master". Pooled: Primary steps down & closes connections. We create a new pooled client and open a new socket for a query. Currently, we make sure we raise an error in this case by not setting slaveOk, so the stepped-down server complains "not master".
|