[SERVER-78694] Change `isStandaloneOrPrimary` checks to use `writesAreReplicated` Created: 06/Jul/23 Updated: 17/Jul/23 |
|
| Status: | Open |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Pierlauro Sciarelli | Assignee: | Backlog - Replication Team |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Assigned Teams: |
Replication
|
||||||||
| Participants: | |||||||||
| Linked BF Score: | 166 | ||||||||
| Description |
|
The shard server op observer is offering the isStandaloneOrPrimary function to verify if a node is primary by checking that writes on the admin database are allowed. The used method from the replication coordinator expects the caller to always hold the RSTL lock or to perform a lock free read, that may not always be the case when observing operations. As of today, the observer is always using the function after checking for the namespace an operation happens on (e.g. here) and by hazard the RSTL lock is always held for those operations. Purpose of this ticket is to make the function resilient to any kind of observable operation and avoid future unsafe usages that may lead to hit the invariant. A solution would be to replace the existing implementation with the following code snippet:
Thank you cheahuychou.mao@mongodb.com for spotting that and proposing a solution! |