In a three-node replica set with default write concerns, what occurs when the primary node experiences a network partition and cannot communicate with the majority of the set?
Trap 1: The primary continues accepting writes until the partition is…
A primary node that cannot reach a majority of its voting members will automatically step down to secondary status. This behavior is a core safety mechanism in MongoDB to prevent stale reads and inconsistent writes in the event of a network failure or a total loss of cluster quorum.
Trap 2: The primary immediately crashes and shuts down the mongod process.
MongoDB does not shut down the mongod process when a partition occurs. Instead, it transitions the primary into a secondary state where it can no longer accept writes, preserving the existing data and allowing it to catch up on replication logs once network connectivity is restored to the set.
Trap 3: The secondary nodes force a rollback on the primary node.
Rollbacks only occur when a former primary rejoins the set and must revert uncommitted operations to match the current majority-confirmed data. The primary node stepping down during a partition is a graceful state transition, not an automatic rollback process, as the existing primary was simply unable to reach majority consensus.
- A
The primary continues accepting writes until the partition is resolved.
Why it fails: A primary node that cannot reach a majority of its voting members will automatically step down to secondary status. This behavior is a core safety mechanism in MongoDB to prevent stale reads and inconsistent writes in the event of a network failure or a total loss of cluster quorum.
- B
The primary immediately crashes and shuts down the mongod process.
Why it fails: MongoDB does not shut down the mongod process when a partition occurs. Instead, it transitions the primary into a secondary state where it can no longer accept writes, preserving the existing data and allowing it to catch up on replication logs once network connectivity is restored to the set.
- C
The primary steps down to secondary status, and the set elects a new primary.
When a primary node detects that it can no longer see a majority of the voting members, it transitions to a secondary state. This is essential for cluster health because it allows the remaining nodes in the replica set to hold an election and select a new primary to handle operations.
- D
The secondary nodes force a rollback on the primary node.
Why it fails: Rollbacks only occur when a former primary rejoins the set and must revert uncommitted operations to match the current majority-confirmed data. The primary node stepping down during a partition is a graceful state transition, not an automatic rollback process, as the existing primary was simply unable to reach majority consensus.