[SERVER-51523] Don't attempt to retrieve a ReshardingCoordinator instance on a replica set secondary Created: 13/Oct/20  Updated: 29/Oct/23  Resolved: 19/Oct/20

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: None
Fix Version/s: 4.9.0

Type: Bug Priority: Major - P3
Reporter: Blake Oler Assignee: Janna Golden
Resolution: Fixed Votes: 0
Labels: PM-234-M1, PM-234-T-lifecycle
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-51209 Fill in missing gaps in Resharding wo... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Sharding 2020-10-19, Sharding 2020-11-02
Participants:

 Description   

When a PrimaryOnlyService service exists on a replica set secondary, it will be in state kPaused. On a primary, it will be in state kRunning.

If one attempts to retrieve an instance while the service is in kPaused, the returned instance will be a boost::none.

OpObservers are run on both primaries and secondaries. This becomes an issue when attempting to run the ReshardingOpObserver, particularly here..

We should prepend a call to PrimaryOnlyService::isRunning() to verify that the PrimaryOnlyService is running before trying to retrieve the instance. Furthermore, we should check if the boost::optional is initialized and throw a DBException anyway, because attempting to index into an uninitialized boost::optional will create a segfault.



 Comments   
Comment by Githook User [ 19/Oct/20 ]

Author:

{'name': 'jannaerin', 'email': 'golden.janna@gmail.com', 'username': 'jannaerin'}

Message: SERVER-51523 Don't attempt to retrieve a ReshardingCoordinator instance on a replica set secondary
Branch: master
https://github.com/mongodb/mongo/commit/4ad809ceae835d19990c19923d37121500d6dae6

Comment by Blake Oler [ 14/Oct/20 ]

From max.hirschhorn in Slack, he could see it being done this way:

auto instance = lookup();
if (!instance) {
    // It is only acceptable for there to not be an instance if the node has already stepped down.
    invariant(!canAcceptWritesFor(...));
    uassert(NotPrimary, ...);
}

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