@@ -14,36 +14,38 @@ Finalize Cutover Process
14
14
15
15
You can finalize a migration and transfer your application
16
16
workload 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.
18
22
19
23
.. note::
20
24
21
25
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`.
25
28
26
29
Steps
27
30
-----
28
31
29
- .. procedure::
30
- :style: normal
32
+ .. procedure::
33
+ :style: normal
34
+
35
+ .. step:: Verify the status of the ``mongosync`` process.
31
36
32
- .. step:: Verify the status of the ``mongosync``
33
- process.
34
-
35
37
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:
39
41
40
- - ``canCommit`` is ``true``.
42
+ - ``canCommit`` is ``true``.
43
+
44
+ - ``lagTimeSeconds`` is small (near ``0``).
41
45
42
- - ``lagTimeSeconds`` is small (near ``0``).
43
-
44
46
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
+
47
49
The following example returns the status of the synchronization process.
48
50
49
51
Request
@@ -60,12 +62,11 @@ Steps
60
62
:copyable: false
61
63
:emphasize-lines: 5, 8
62
64
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.
65
66
66
67
- If you started ``mongosync`` with ``enableUserWriteBlocking``
67
68
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.
69
70
- If you didn't start ``mongosync`` with
70
71
``enableUserWriteBlocking``, ensure that writes are disabled.
71
72
For example, run the :dbcommand:`setUserWriteBlockMode` command on the
81
82
- If ``mongosync`` uses filtered sync, it's not necessary to
82
83
disable writes to the entire source cluster. But you must ensure
83
84
that write operations are stopped for the collections included
84
- by the filter.
85
+ by the filter.
85
86
86
87
.. step:: Send a :ref:`commit <c2c-api-commit>` request to ``mongosync``.
87
88
@@ -102,10 +103,10 @@ Steps
102
103
:language: json
103
104
:copyable: false
104
105
105
- .. note::
106
+ .. note::
106
107
107
108
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
109
110
``COMMITTED``.
110
111
111
112
.. step:: Wait until you can perform writes on the destination cluster.
@@ -114,41 +115,18 @@ Steps
114
115
``true``. If ``canWrite`` is ``false``, wait until ``progress``
115
116
shows ``canWrite`` is ``true``.
116
117
117
- Request
118
- ~~~~~~~
119
-
120
- .. literalinclude:: /includes/api/requests/progress.sh
121
- :language: shell
118
+ .. io-code-block::
119
+ :copyable: true
122
120
123
- Response
124
- ~~~~~~~~
121
+ .. input::
122
+ :language: bash
125
123
126
- .. code-block:: json
127
- :emphasize-lines: 6
128
- :copyable: false
124
+ curl -sS localhost:27182/api/v1/progress -XGET | jq ".progress.canWrite"
129
125
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
151
128
129
+ true
152
130
153
131
.. step:: Verify data transfer.
154
132
@@ -164,54 +142,62 @@ Steps
164
142
.. code-block:: javascript
165
143
166
144
db.adminCommand(
167
- {
168
- setUserWriteBlockMode: 1,
169
- global: false
170
- }
145
+ {
146
+ setUserWriteBlockMode: 1,
147
+ global: false
148
+ }
171
149
)
172
150
151
+ Then, transfer your application workload to the destination cluster.
152
+
173
153
.. step:: Call the ``progress`` endpoint to determine the status of the ``mongosync`` process.
174
154
175
- When the ``mongosync`` progress response indicates that the
155
+ When the ``mongosync`` progress response indicates that the
176
156
``mongosync`` state is ``COMMITTED``, the cutover process is
177
- complete.
157
+ complete.
178
158
179
- Request
180
- ~~~~~~~
159
+ .. io-code-block::
160
+ :copyable: true
181
161
182
- .. literalinclude:: /includes/api/requests/progress.sh
183
- :language: shell
162
+ .. input::
163
+ :language: bash
184
164
185
- Response
186
- ~~~~~~~~
165
+ curl -sS localhost:27182/api/v1/progress -XGET | jq ".progress.state"
187
166
188
- .. code-block:: json
189
- :emphasize-lines: 4
190
- :copyable: false
167
+ .. output::
168
+ :language: json
191
169
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"
213
171
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::
214
195
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.
215
201
216
202
Learn More
217
203
----------
0 commit comments