Navigation
This version of the documentation is archived and no longer supported.

Replica Set Member States

On this page

Members of replica sets have states that reflect the startup process, basic operations, and potential error states.

Number Name State Description
0 STARTUP Cannot vote. All members start up in this state. The mongod parses the replica set configuration document while in STARTUP.
1 PRIMARY Can vote. The primary is the only member to accept write operations.
2 SECONDARY Can vote. The secondary replicates the data store.
3 RECOVERING Can vote. Members either perform startup self-checks, or transition from completing a rollback or resync.
4 FATAL Cannot vote. Has encountered an unrecoverable error.
5 STARTUP2 Cannot vote. Forks replication and election threads before becoming a secondary.
6 UNKNOWN Cannot vote. Has never connected to the replica set.
7 ARBITER Can vote. Arbiters do not replicate data and exist solely to participate in elections.
8 DOWN Cannot vote. Is not accessible to the set.
9 ROLLBACK Can vote. Performs a rollback.
10 REMOVED Cannot vote. Was once in the replica set but has now been removed.

States

Core States

PRIMARY

Members in PRIMARY state accept write operations. A replica set has only one primary at a time. A SECONDARY member becomes primary after an election. Members in the PRIMARY state are eligible to vote.

SECONDARY

Members in SECONDARY state 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 the PRIMARY state if the primary becomes unavailable.

ARBITER

Members in ARBITER state 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 the ARBITER state if the set would otherwise have an even number of members, and could suffer from tied elections. Like primaries, there should only be at most one arbiter in any replica set.

See Replica Set Members for more information on core states.

Initialization States

STARTUP

Each member of a replica set starts up in STARTUP state. mongod then loads that member’s replica set configuration, and transitions the member’s state to STARTUP2. Members in STARTUP are not eligible to vote.

STARTUP2

Each member of a replica set enters the STARTUP2 state as soon as mongod finishes loading that member’s configuration. While in the STARTUP2 state, the member creates threads to handle internal replication operations. Members are in the STARTUP2 state for a short period of time before entering the RECOVERING state. Members in the STARTUP2 state are not eligible to vote.

RECOVERING

A member of a replica set enters RECOVERING state when it is not ready to accept reads. The RECOVERING state can occur during normal operation, and doesn’t necessarily reflect an error condition. Members in the RECOVERING state are eligible to vote in elections, but is not eligible to enter the PRIMARY state.

During startup, members transition through RECOVERING after STARTUP2 and before becoming SECONDARY.

During normal operation, if a secondary falls behind the other members of the replica set, it may need to resync with the rest of the set. While resyncing, the member enters the RECOVERING state.

Whenever the replica set replaces a primary in an election, the old primary’s data collection may contain documents that did not have time to replicate to the secondary members. In this case the member rolls back those writes. During rollback, the member will have RECOVERING state.

On secondaries, the compact and replSetMaintenance commands force the secondary to enter RECOVERING state. This prevents clients from reading during those operations.

Error States

Members in any error state can’t vote.

FATAL

Members that encounter an unrecoverable error enter the FATAL state. Members in this state requires administrator intervention.

UNKNOWN

Members that have never communicated status information to the replica set are in the UNKNOWN state.

DOWN

Members that lose their connection to the replica set enter the DOWN state.

REMOVED

Members that are removed from the replica set enter the REMOVED state. When members enter the REMOVED state, the logs will mark this event with a replSet REMOVED message entry.

ROLLBACK

When a SECONDARY rolls back a write operation after transitioning from PRIMARY, it enters the ROLLBACK state. See Rollbacks During Replica Set Failover.