[SERVER-43310] mongos tries to connect to the secondary to create the index if `rs.slaveOk()` is set. Created: 13/Sep/19 Updated: 29/Oct/23 Resolved: 02/Jan/20 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 4.2.3, 4.3.3 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Linda Qin | Assignee: | Blake Oler |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | KP42, sharding-wfbf-day | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||||||||||
| Operating System: | ALL | ||||||||||||||||||||||||||||
| Backport Requested: |
v4.2
|
||||||||||||||||||||||||||||
| Steps To Reproduce: |
|
||||||||||||||||||||||||||||
| Sprint: | Sharding 2019-12-02, Sharding 2019-12-16, Sharding 2019-12-30, Sharding 2020-01-13 | ||||||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||||||
| Case: | (copied to CRM) | ||||||||||||||||||||||||||||
| Description |
|
On the mongos, we can run rs.slaveOk() to set the read preference to secondaryPreferred. After running rs.slaveOk() on the mongos, the insert operation will still be routed to the primary so the insert will succeed. However, ensureIndex will be routed to the secondary, so this command would fail. |
| Comments |
| Comment by Githook User [ 02/Jan/20 ] |
|
Author: {'name': 'Blake Oler', 'email': 'blake.oler@mongodb.com', 'username': 'BlakeIsBlake'}Message: (cherry picked from commit bbca8dbaf5a32ece935d2a14a8d7f94da41378e3) |
| Comment by Githook User [ 02/Jan/20 ] |
|
Author: {'name': 'Blake Oler', 'email': 'blake.oler@mongodb.com', 'username': 'BlakeIsBlake'}Message: |
| Comment by Esha Maharishi (Inactive) [ 18/Nov/19 ] |
|
I think the issue is that the createIndexes command on mongosĀ uses the readPreference on the OperationContext. It should be pretty easy to just change that line to use ReadPreference:PrimaryOnly like enableSharding does. |