Docs Home → MongoDB Cluster-to-Cluster Sync
mongosync
States
mongosync
enters different states depending on the requests it
receives. mongosync
can only be in a single state at a given time.
The current mongosync
states determines which API operations you can
run.
This page describes mongosync
states.
View the Current State
To view the current state of mongosync
, use the /progress. endpoint. The /progress
endpoint returns the state in the state
field.
State Descriptions
The following table describes each state and lists the permitted operations in that state.
State | Description | Possible API Operations |
---|---|---|
| mongosync is initialized and ready for a sync job to
begin. | |
RUNNING | The sync process is currently running. In this state, data is
initially synced to the destination cluster. Subsequent writes to
the source cluster are applied to the destination cluster. | |
PAUSED | The sync process is paused. To resume the sync process, send a
request to the /resume endpoint. | |
| The cutover for the sync process has started. The time it takes
to transition to the COMMITTED phase depends on
lagTimeSeconds . To monitor lagTimeSeconds or to see if
mongosync has finished committing, use the /progress endpoint. |
|
COMMITTED | The cutover for the sync process is complete. |
|
Read Operations
Read operations on the source cluster are always permitted.
When the /progress
endpoint reports canWrite
is true
, the
data on the source and destination clusters is consistent.
Write Operations
To see what state mongosync
is in, call the /progress API endpoint. The /progress
output includes a
boolean value, canWrite
.
When
canWrite
istrue
, it is safe to write to the destination cluster.When
canWrite
isfalse
, do not write to the destination cluster.
You can safely write to the source cluster while mongosync
is
syncing. Do not write to the destination cluster unless canWrite
is
true
.
Write-blocking
When write-blocking is enabled, mongosync
blocks writes:
On the destination cluster during sync
On the source cluster while committing
To enable write-blocking, use the start API
to set enableUserWriteBlocking
to true
. You cannot enable
write-blocking after the sync starts.
To set enableUserWriteBlocking
, the mongosync
user must have a
role that includes the setUserWriteBlockMode
and
bypassWriteBlockingMode
ActionTypes.
Note
When using enableUserWriteBlocking
, writes are only blocked for users
that do not have the bypassWriteBlockingMode
ActionType. Users
who have this ActionType are able to perform writes.