[SERVER-61971] Ensure that the isStandaloneOrPrimary function is defined and used correctly Created: 09/Dec/21  Updated: 17/Jul/23

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

Type: Task Priority: Major - P3
Reporter: Antonio Fuschetto Assignee: Backlog - Replication Team
Resolution: Unresolved Votes: 0
Labels: former-quick-wins
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-78694 Change `isStandaloneOrPrimary` checks... Open
Assigned Teams:
Replication
Participants:

 Description   

To determine if the current mongod process is the primary or a secondary, the isStandaloneOrPrimary function is typically defined and used despite the presence of similar functions (see TTL monitor).

Evaluate which function is correct to use and align existing code based on the outcome of that evaluation.



 Comments   
Comment by Kaloian Manassiev [ 16/Dec/21 ]

Generally, there are way too many ways for a caller to check whether a node is a primary (e.g., ReplicationCoordinator::canAcceptWrites, the member states, etc). I am going to move this ticket to the replication team to provide us with a guide (in the form or arch guide article or some functions) for what exactly callers should be using to determine primary and what are the situations that are valid to ask that.

Comment by Antonio Fuschetto [ 10/Dec/21 ]

jason.chan (from Replication team) and I discussed about the best way to check at runtime if the current mongod process is a primary or a secondary node. The canAcceptNonLocalWrites function seems to be the best solution, and this should be used where the isStandaloneOrPrimary function is currently used.

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