replSetMaintenance
Definition
replSetMaintenance
- The
replSetMaintenance
admin command enables or disables themaintenance mode for a secondary member of a replicaset.
The command has the following prototype form:
- { replSetMaintenance: <boolean> }
Behavior
Consider the following behavior when running thereplSetMaintenance
command:
- You cannot run the command on the Primary.
- You must run the command against the
admin
database. - When enabled
replSetMaintenance: true
, the member enters theRECOVERING
state. While the secondary isRECOVERING
:- The member is not accessible for read operations.
- The member continues to sync its oplog from the Primary.
- When a node receives a
replSetMaintenance: true
request, itadds a maintenance mode task to a queue of tasks. If the queue oftasks was empty and now is not, the node will transition toRECOVERING
state and begin to reject read requests. When a nodereceives areplSetMaintenance: false
request, it removes amaintenance mode task from the queue (even if that task wasinitiated by a different client). If the request emptiesthe maintenance mode task queue, the node will return toSECONDARY
state. - If you want to prevent a node from servicing reads, consider usingHidden Replica Set Members instead.