C100DBA · Question #110
Given a replica set with five data-bearing members, suppose the primary goes down with operations in its oplog that have been copied from the primary to only one secondary. Assuming no other…
The correct answer is B. the secondary with the most current oplog will be elected primary. Option B is correct because MongoDB's election algorithm favors the secondary with the highest oplog timestamp - meaning the secondary that received those extra operations is most likely to win the election. With five members, four remain available (far exceeding the majority…
Question
Given a replica set with five data-bearing members, suppose the primary goes down with operations in its oplog that have been copied from the primary to only one secondary. Assuming no other problems occur, which of the following describes what is most likely to happen?
Options
- Amissing operations will need to be manually re-performed
- Bthe secondary with the most current oplog will be elected primary
- Creads will be stale until the primary comes back up
- Dthe primary may roll back the operations once it recovers
- Ethe most current secondary will roll back the operations following the election
How the community answered
(48 responses)- A2% (1)
- B69% (33)
- C8% (4)
- D17% (8)
- E4% (2)
Explanation
Option B is correct because MongoDB's election algorithm favors the secondary with the highest oplog timestamp - meaning the secondary that received those extra operations is most likely to win the election. With five members, four remain available (far exceeding the majority of three required), so an election proceeds immediately and those operations are preserved on the new primary.
Why the distractors fail:
- A is wrong because no manual intervention is needed - the election mechanism automatically promotes the most up-to-date node, preserving the operations.
- C is wrong because a new primary is elected automatically from the four healthy members; reads don't remain stale waiting for the old primary.
- D has the causality backwards: when the old primary rejoins, it becomes a secondary and may need to roll back any divergent operations - not the other way around.
- E is wrong because the most current secondary becomes the new primary and keeps those operations; it has no reason to roll them back.
Memory tip: Think "newest log wins the crown." In a replica set election, MongoDB crowns the node with the freshest oplog as primary, ensuring the most recent writes survive - so data follows the leader, not the other way around.
Topics
Community Discussion
No community discussion yet for this question.