All servers in a replica set maintain regular communication with every other member via a heartbeat. The heartbeat is a small packet sent regularly to verify that all members are operating normally.
Secondary members also communicate with the primary to get the latest updates from the oplog and apply them to their own data.
The information here refers to the latest replication election protocol, version 1, which was introduced in MongoDB v3.2.
Schematically, we can see how this works:
When the primary member goes down, all secondaries will miss a heartbeat or more. They will be waiting up until settings.electionTimeoutMillis time passes (default 10 seconds) and then the secondaries start one or more rounds of elections to find the new primary.
For a server to be elected as primary from the secondaries it must have two properties:
- Belong in a group of voters...