@@ -14,36 +14,38 @@ Finalize Cutover Process
1414
1515You can finalize a migration and transfer your application
1616workload from the source to the destination cluster using the
17- :ref:`mongosync <c2c-mongosync>` cutover process.
17+ :ref:`mongosync <c2c-mongosync>` cutover process.
18+
19+ ``mongosync`` should remain active until it reaches the
20+ :ref:`COMMITTED <c2c-state-committed>` state. This allows ``mongosync`` to sync
21+ any additional writes that occur during the migration.
1822
1923.. note::
2024
2125 Before you switch your application workload to the
22- destination cluster, you should always verify that the sync
23- was successful. For more information, see
24- :ref:`c2c-verification`.
26+ destination cluster, you should always verify a successful sync.
27+ For more information, see :ref:`c2c-verification`.
2528
2629Steps
2730-----
2831
29- .. procedure::
30- :style: normal
32+ .. procedure::
33+ :style: normal
34+
35+ .. step:: Verify the status of the ``mongosync`` process.
3136
32- .. step:: Verify the status of the ``mongosync``
33- process.
34-
3537 Call the :ref:`progress <c2c-api-progress>` endpoint to determine
36- the status of ``mongosync`` before starting the cutover process.
37- Ensure that the ``mongosync`` process status indicates the
38- following values:
38+ the status of ``mongosync`` before starting the cutover process.
39+ Ensure that the ``mongosync`` process status indicates the
40+ following values:
3941
40- - ``canCommit`` is ``true``.
42+ - ``canCommit`` is ``true``.
43+
44+ - ``lagTimeSeconds`` is small (near ``0``).
4145
42- - ``lagTimeSeconds`` is small (near ``0``).
43-
4446 If ``lagTimeSeconds`` isn't close to ``0`` when the cutover
45- starts, cutover might take a long time.
46-
47+ starts, cutover might take a long time.
48+
4749 The following example returns the status of the synchronization process.
4850
4951 Request
@@ -60,12 +62,11 @@ Steps
6062 :copyable: false
6163 :emphasize-lines: 5, 8
6264
63-
64- .. step:: Stop any write operations to the synced collections on the source.
65+ .. step:: Stop any write operations to the synced collections on the source.
6566
6667 - If you started ``mongosync`` with ``enableUserWriteBlocking``
6768 set to ``true``, ``mongosync`` blocks all write operations on
68- the entire source cluster during the commit (step 4) for you.
69+ the entire source cluster during the commit (step 4) for you.
6970 - If you didn't start ``mongosync`` with
7071 ``enableUserWriteBlocking``, ensure that writes are disabled.
7172 For example, run the :dbcommand:`setUserWriteBlockMode` command on the
8182 - If ``mongosync`` uses filtered sync, it's not necessary to
8283 disable writes to the entire source cluster. But you must ensure
8384 that write operations are stopped for the collections included
84- by the filter.
85+ by the filter.
8586
8687 .. step:: Send a :ref:`commit <c2c-api-commit>` request to ``mongosync``.
8788
@@ -102,10 +103,10 @@ Steps
102103 :language: json
103104 :copyable: false
104105
105- .. note::
106+ .. note::
106107
107108 After you submit a ``commit`` request, call the ``progress`` endpoint
108- to ensure that the ``mongosync`` state is ``COMMITTING`` or
109+ to ensure that the ``mongosync`` state is ``COMMITTING`` or
109110 ``COMMITTED``.
110111
111112 .. step:: Wait until you can perform writes on the destination cluster.
@@ -114,41 +115,18 @@ Steps
114115 ``true``. If ``canWrite`` is ``false``, wait until ``progress``
115116 shows ``canWrite`` is ``true``.
116117
117- Request
118- ~~~~~~~
119-
120- .. literalinclude:: /includes/api/requests/progress.sh
121- :language: shell
118+ .. io-code-block::
119+ :copyable: true
122120
123- Response
124- ~~~~~~~~
121+ .. input::
122+ :language: bash
125123
126- .. code-block:: json
127- :emphasize-lines: 6
128- :copyable: false
124+ curl -sS localhost:27182/api/v1/progress -XGET | jq ".progress.canWrite"
129125
130- {
131- "progress":
132- {
133- "state":"COMMITTED",
134- "canCommit":true,
135- "canWrite":true,
136- "info":"change event application",
137- "lagTimeSeconds":0,
138- "collectionCopy":
139- {
140- "estimatedTotalBytes":694,
141- "estimatedCopiedBytes":694
142- },
143- "directionMapping":
144- {
145- "Source":"cluster0: localhost:27017",
146- "Destination":"cluster1: localhost:27018"
147- }
148- },
149- "success": true
150- }
126+ .. output::
127+ :language: json
151128
129+ true
152130
153131 .. step:: Verify data transfer.
154132
@@ -164,54 +142,62 @@ Steps
164142 .. code-block:: javascript
165143
166144 db.adminCommand(
167- {
168- setUserWriteBlockMode: 1,
169- global: false
170- }
145+ {
146+ setUserWriteBlockMode: 1,
147+ global: false
148+ }
171149 )
172150
151+ Then, transfer your application workload to the destination cluster.
152+
173153 .. step:: Call the ``progress`` endpoint to determine the status of the ``mongosync`` process.
174154
175- When the ``mongosync`` progress response indicates that the
155+ When the ``mongosync`` progress response indicates that the
176156 ``mongosync`` state is ``COMMITTED``, the cutover process is
177- complete.
157+ complete.
178158
179- Request
180- ~~~~~~~
159+ .. io-code-block::
160+ :copyable: true
181161
182- .. literalinclude:: /includes/api/requests/progress.sh
183- :language: shell
162+ .. input::
163+ :language: bash
184164
185- Response
186- ~~~~~~~~
165+ curl -sS localhost:27182/api/v1/progress -XGET | jq ".progress.state"
187166
188- .. code-block:: json
189- :emphasize-lines: 4
190- :copyable: false
167+ .. output::
168+ :language: json
191169
192- {
193- "progress":
194- {
195- "state":"COMMITTED",
196- "canCommit":true,
197- "canWrite":false,
198- "info":"change event application",
199- "lagTimeSeconds":0,
200- "collectionCopy":
201- {
202- "estimatedTotalBytes":694,
203- "estimatedCopiedBytes":694
204- },
205- "directionMapping":
206- {
207- "Source":"cluster0: localhost:27017",
208- "Destination":"cluster1: localhost:27018"
209- }
210- },
211- "success": true
212- }
170+ "COMMITTED"
213171
172+ Behavior
173+ --------
174+
175+ .. _c2c-canWrite-committed:
176+
177+ canWrite and COMMITTED
178+ ~~~~~~~~~~~~~~~~~~~~~~
179+
180+ ``mongosync`` permits writes on the destination cluster at an
181+ earlier stage than the ``COMMITTED`` state.
182+
183+ In the initial sync, ``mongosync`` replicates unique indexes on
184+ the source cluster as non-unique indexes on the destination
185+ cluster. During commit, the relevant non-unique indexes on the
186+ destination cluster are set to ``prepareUnique``. When this is
187+ done, the ``/progress`` endpoint begins to return ``canWrite:
188+ true``. Collections with ``prepareUnique`` indexes reject
189+ new documents that violate the unique index constraint.
190+ ``mongosync`` then converts the ``prepareUnique``
191+ indexes into unique indexes. When this is done, ``mongosync``
192+ changes its state to ``COMMITTED``.
193+
194+ .. note::
214195
196+ The conversion of ``prepareUnique`` indexes to unique
197+ indexes can be resource intensive when syncing large
198+ collections. This can result in a long time between the
199+ ``/progress`` endpoint returning ``canWrite: true`` and
200+ ``mongosync`` reaching the ``COMMITTED`` state.
215201
216202Learn More
217203----------
0 commit comments