- Replication >
- Replication Reference >
- Replica Set Member States
Replica Set Member States¶
On this page
Each member of a replica set has a state that reflects its disposition within the set.
| Number | Name | State Description |
|---|---|---|
| 0 | STARTUP |
Not yet an active member of any set. All members start up in this state. The
mongod parses the replica set configuration document while in STARTUP. |
| 1 | PRIMARY |
The member in state primary is the only member that can accept write operations. |
| 2 | SECONDARY |
A member in state secondary is replicating the data store. Data is available for reads, although they may be stale. |
| 3 | RECOVERING |
Can vote. Members either perform startup self-checks, or transition from completing a rollback or resync. |
| 5 | STARTUP2 |
The member has joined the set and is running an initial sync. |
| 6 | UNKNOWN |
The member’s state, as seen from another member of the set, is not yet known. |
| 7 | ARBITER |
Arbiters do not replicate data and exist solely to participate in elections. |
| 8 | DOWN |
The member, as seen from another member of the set, is unreachable. |
| 9 | ROLLBACK |
This member is actively performing a rollback. Data is not available for reads. |
| 10 | REMOVED |
This member was once in a replica set but was subsequently removed. |
States¶
Core States¶
-
PRIMARY¶ Members in
PRIMARYstate accept write operations. A replica set has at most one primary at a time. ASECONDARYmember becomes primary after an election. Members in thePRIMARYstate are eligible to vote.
-
SECONDARY¶ Members in
SECONDARYstate replicate the primary’s data set and can be configured to accept read operations. Secondaries are eligible to vote in elections, and may be elected to thePRIMARYstate if the primary becomes unavailable.
-
ARBITER¶ Members in
ARBITERstate do not replicate data or accept write operations. They are eligible to vote, and exist solely to break a tie during elections. Replica sets should only have a member in theARBITERstate if the set would otherwise have an even number of members, and could suffer from tied elections. There should only be at most one arbiter configured in any replica set.
See Replica Set Members for more information on core states.
Other States¶
-
STARTUP¶ Each member of a replica set starts up in
STARTUPstate.mongodthen loads that member’s replica set configuration, and transitions the member’s state toSTARTUP2. Members inSTARTUPare not eligible to vote, as they are not yet a recognized member of any replica set.
-
STARTUP2¶ Each member of a replica set enters the
STARTUP2state as soon asmongodfinishes loading that member’s configuration, at which time it becomes an active member of the replica set. The member then decides whether or not to undertake an initial sync. If a member begins an initial sync, the member remains inSTARTUP2until all data is copied and all indexes are built. Afterwards, the member transitions toRECOVERING.
-
RECOVERING¶ A member of a replica set enters
RECOVERINGstate when it is not ready to accept reads. TheRECOVERINGstate can occur during normal operation, and doesn’t necessarily reflect an error condition. Members in theRECOVERINGstate are eligible to vote in elections, but are not eligible to enter thePRIMARYstate.A member transitions from
RECOVERINGtoSECONDARYafter replicating enough data to guarantee a consistent view of the data for client reads. The only difference betweenRECOVERINGandSECONDARYstates is thatRECOVERINGprohibits client reads andSECONDARYpermits them.SECONDARYstate does not guarantee anything about the staleness of the data with respect to the primary.Due to overload, a secondary may fall far enough behind the other members of the replica set such that it may need to resync with the rest of the set. When this happens, the member enters the
RECOVERINGstate and requires manual intervention.
Error States¶
Members in any error state can’t vote.
-
UNKNOWN¶ Members that have never communicated status information to the replica set are in the
UNKNOWNstate.
-
DOWN¶ Members that lose their connection to the replica set are seen as
DOWNby the remaining members of the set.
-
REMOVED¶ Members that are removed from the replica set enter the
REMOVEDstate. When members enter theREMOVEDstate, the logs will mark this event with areplSet REMOVEDmessage entry.