Skip to content

Commit d3ef66d

Browse files
authored
DOCS-15702 Static Unlike Topologies (#101)
* DOCS-15702 Documents sync of Static Unlike Topologies * Refactors sharding options * Updates sharding options * Expanded behavior section for static unlike * Updates limitations * Rename behavior * Updates sharding table * Adds sharding example * Fixes build issue * Fixes build issue * Fixes per Jeff * Fixes per Jeff * Fixes per Jeff * Fixes per Frederic Vitzikam * Fixes per Frederic Vitzikam * Fixes per Frederic Vitzikam * Fixes per Frederic Vitzikam * Fixes build issue * Fixes per Frederic Vitzikam * Fixes per Frederic Vitzikam * Fixes per Frederic Vitzikam * Fixes per Frederic Vitzikam * Refactors synchronization to sync * Refactors synchronization to sync * Fixes per Frederic * Fix per Frederic
1 parent f066059 commit d3ef66d

File tree

3 files changed

+240
-11
lines changed

3 files changed

+240
-11
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
curl localhost:27182/api/v1/start -XPOST \
2+
--data '
3+
{
4+
"source": "cluster0",
5+
"destination": "cluster1",
6+
"sharding": {
7+
"createSupportingIndexes": true,
8+
"shardingEntries": [
9+
{
10+
"database": "accounts",
11+
"collection": "us_east",
12+
"shardCollection": {
13+
"key": [
14+
{ "location": 1 },
15+
{ "region": 1 },
16+
]
17+
}
18+
}
19+
]
20+
}
21+
} '

source/reference/api/start.txt

Lines changed: 205 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,30 @@ Request Body Parameters
9494
* - ``reversible``
9595
- boolean
9696
- Optional
97-
- If set to ``true``, enables the synchronization operation to be
98-
reversed. For more information, see the :ref:`reverse
99-
<c2c-api-reverse>` endpoint.
97+
- If set to ``true``, enables the sync operation to be
98+
reversed.
99+
100+
This option is not supported for the following configurations:
101+
102+
* Sync from a replica set to a sharded cluster
103+
104+
* Sync sharded clusters that have different numbers of shards
105+
106+
For more information, see the :ref:`reverse <c2c-api-reverse>` endpoint.
100107

101108
Default value is ``false``.
102109

110+
* - ``sharding``
111+
- document
112+
- Optional
113+
- Configure sync between a replica set and sharded cluster.
114+
Sync from a replica set to a sharded cluster requires this
115+
option.
116+
117+
For more information, see :ref:`c2c-api-start-sharding`.
118+
119+
.. versionadded:: 1.1
120+
103121
* - ``enableUserWriteBlocking``
104122
- boolean
105123
- Optional
@@ -111,6 +129,69 @@ Request Body Parameters
111129

112130
Default value is ``false``.
113131

132+
133+
.. _c2c-api-start-sharding:
134+
135+
Sharding Parameters
136+
~~~~~~~~~~~~~~~~~~~
137+
138+
.. versionadded:: 1.1
139+
140+
To sync from a replica set to a sharded cluster, set the
141+
``sharding`` option to shard collections on the destination cluster.
142+
143+
The ``sharding`` option has the following parameters:
144+
145+
.. list-table::
146+
:header-rows: 1
147+
:stub-columns: 1
148+
:widths: 15 15 70
149+
150+
* - Parameter
151+
- Type
152+
- Description
153+
154+
* - ``createSupportedIndexes``
155+
- boolean
156+
- Optional. Sets whether sync creates a supporting index
157+
for the shard key, if none exists. Defaults to ``false``.
158+
159+
* - ``shardingEntries``
160+
- array of documents
161+
- Required. Sets the namespace and key of collections to shard
162+
during sync.
163+
164+
Collections not included in this array sync to unsharded
165+
collections on the destination cluster. If set with an empty array,
166+
no collections are sharded.
167+
168+
* - | ``shardingEntries``
169+
| ``.collection``
170+
- string
171+
- Sets the collection to shard.
172+
173+
* - | ``shardingEntries``
174+
| ``.database``
175+
- string
176+
- Sets the database of the collection to shard.
177+
178+
* - | ``shardingEntries``
179+
| ``.shardCollection``
180+
- document
181+
- Sets the shard key to generate on the destination cluster.
182+
183+
* - | ``shardingEntries``
184+
| ``.shardCollection``
185+
| ``.key``
186+
- array
187+
- Sets the fields to use for the shard key.
188+
189+
For more information, see :ref:`shard-key`.
190+
191+
``mongosync`` throws an error if the ``sharding`` option is not set when
192+
syncing from a replica set to a sharded cluster. ``mongosync`` also
193+
throws an error if the ``sharding`` option is set with any other configuration.
194+
114195
Response
115196
--------
116197

@@ -151,12 +232,133 @@ Request
151232
Response
152233
~~~~~~~~
153234

235+
.. literalinclude:: /includes/api/responses/success.json
236+
:language: json
237+
:copyable: false
238+
239+
Example 3 - Start Sync from Replica Set to Sharded Cluster
240+
----------------------------------------------------------
241+
242+
Request
243+
~~~~~~~
244+
245+
.. literalinclude:: /includes/api/requests/start-rs-shard.sh
246+
:language: shell
247+
248+
Response
249+
~~~~~~~~
250+
154251
.. literalinclude:: /includes/api/responses/success.json
155252
:language: json
156253
:copyable: false
157254

158255
Behavior
159256
--------
160257

258+
State
259+
~~~~~
260+
161261
If the ``start`` request is successful, ``mongosync`` enters the
162262
``RUNNING`` state.
263+
264+
Pre-Split Chunks
265+
~~~~~~~~~~~~~~~~
266+
267+
.. versionadded:: 1.1
268+
269+
When ``mongosync`` syncs to a sharded cluster, it pre-splits chunks for
270+
sharded collections on the destination cluster. This is supported in the
271+
following configurations:
272+
273+
* Sync from a replica set to a sharded cluster.
274+
275+
* Sync between sharded clusters that differ in the number of shards.
276+
277+
278+
Shard Replica Sets
279+
~~~~~~~~~~~~~~~~~~
280+
281+
.. versionadded:: 1.1
282+
283+
Sync from a replica set to a sharded cluster requires the
284+
``sharding`` option. This option configures how ``mongosync`` shards
285+
collections.
286+
287+
The ``sharding.shardEntries`` array specifies the collections to shard.
288+
Collections that are not listed in this array replicate as unsharded.
289+
290+
Supporting Indexes
291+
~~~~~~~~~~~~~~~~~~
292+
293+
.. versionadded:: 1.1
294+
295+
``mongosync`` syncs indexes from the source cluster to the destination
296+
cluster. But, when syncing from a replica set to a sharded cluster,
297+
``mongosync`` may require an additional index to support the shard key,
298+
which may not exist on the source cluster.
299+
300+
``mongosync`` can create supporting indexes for sharded collections during sync.
301+
This is done by setting the ``sharding.createSupportingIndexes`` option.
302+
303+
When ``sharding.createSupportingIndexes`` is ``false`` (the default):
304+
305+
* Each shard key you provide for the ``sharding.shardEntries`` option
306+
must have an existing index on the source cluster.
307+
308+
* One of the indexes used for the shard key must have simple collation if the
309+
collection uses any other collation.
310+
311+
* To use a unique index in the shard key, you must specify its uniqueness when
312+
you create the index on the source cluster.
313+
314+
* Unique indexes on the source cluster that are incompatible with the requested
315+
shard key on the destination cluster, such as a unique index on the source
316+
that does not contain the requested shard key as a prefix on the destination,
317+
can cause ``mongosync`` to fail.
318+
319+
When ``sharding.createSupportingIndexes`` is ``true``:
320+
321+
* If the supporting indexes exist on the source cluster, ``mongosync``
322+
syncs the indexes to the destination cluster and uses them
323+
as shard keys.
324+
325+
* If the supporting indexes don't exist, ``mongosync`` creates them on the
326+
destination cluster.
327+
328+
The ``sharding.createSupportingIndexes`` option affects all sharded collections.
329+
330+
Rename During Sync
331+
~~~~~~~~~~~~~~~~~~
332+
333+
.. versionadded:: 1.1
334+
335+
Collections listed in the ``sharding.shardEntries`` array
336+
when synced from a replica set to a sharded cluster
337+
become sharded collections on the destination cluster.
338+
339+
Renaming a collection (such as with the :dbcommand:`renameCollection` command)
340+
on the source cluster after calling ``start`` but before ``mongosync`` begins
341+
to copy the collection can block the collection from sharding on the destination.
342+
343+
.. note::
344+
345+
Renaming collections to use a different database while syncing from a
346+
replica set to a sharded cluster is not supported.
347+
348+
349+
To check whether it is safe to rename collections, call the
350+
:ref:`c2c-api-progress` endpoint and check the value of the
351+
``collectionCopy.estimatedCopiedBytes`` field in the return document.
352+
353+
* A value of 0 indicates that ``mongosync`` has not started to copy the
354+
collection.
355+
356+
Renaming a collection at this point may result in an unsharded collection
357+
on the destination cluster, as the transition to copying can happen before
358+
the rename takes effect on the source.
359+
360+
* A value greater than 0 indicates that ``mongosync`` has started the copy.
361+
Renaming the collection from this point on does not block
362+
its sharding on the destination cluster, even in the event of a crash.
363+
364+

source/reference/limitations.txt

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,20 @@ Unsupported Collection Types
8383
Sharded Clusters
8484
----------------
8585

86-
- The :ref:`shard topologies <sharding-introduction>` must be the same
87-
in the source and target clusters. The following configurations are
88-
not supported.
89-
90-
- Replica set to sharded cluster.
91-
- Sharded cluster to replica set.
92-
- Unequal numbers of source and destination shards.
86+
- ``mongosync`` does not support sync from a sharded cluster
87+
to a replica set.
88+
- Sync from a replica set to a sharded cluster has the following
89+
limitations:
90+
91+
- Collections included in the ``sharding.shardingEntries`` option for the
92+
:ref:`c2c-api-start` command cannot be renamed to use a different
93+
database while ``mongosync`` is running.
94+
- When using the ``sharding.createSupprtingIndexes`` option to create indexes
95+
supporting shard keys on the destination cluster during sync,
96+
you cannot create these indexes afterwards on the source cluster.
97+
98+
The index must either exist before ``mongosync`` starts or be created after
99+
the migration is complete and ``mongosync`` has stopped.
93100
- Within a collection, the ``_id`` field must be unique across all of
94101
the shards in the cluster. See :ref:`sharded-clusters-unique-indexes`
95102
for more details.
@@ -107,7 +114,6 @@ Sharded Clusters
107114
<sharding-shard-key-indexes>` is one lower than normal, 63 instead of
108115
64.
109116

110-
111117
Reversing
112118
---------
113119

0 commit comments

Comments
 (0)