Skip to content

Commit 4be6789

Browse files
authored
DOCS-15363 documents moveRange (#1947) (#1985)
* documents moveRange * review feedback * restores moveChunk() method * cleanup * toShard * removes moveChunk * updates * revert 2.6 * revert * review feedback * review feedback
1 parent f0c91b1 commit 4be6789

11 files changed

+308
-55
lines changed

source/core/sharding-balancer-administration.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,10 @@ All chunk migrations use the following procedure:
138138
#. The balancer process sends the :dbcommand:`moveChunk` command to
139139
the source shard.
140140

141-
#. The source starts the move with an internal :dbcommand:`moveChunk`
142-
command. During the migration process, operations to the chunk
143-
route to the source shard. The source shard is responsible for
144-
incoming write operations for the chunk.
141+
#. The source starts the move when it receives an internal
142+
:dbcommand:`moveRange` command. During the migration process,
143+
operations to the chunk are sent to the source shard. The source
144+
shard is responsible for incoming write operations for the chunk.
145145

146146
#. The destination shard builds any indexes required by the source
147147
that do not exist on the destination.
@@ -235,8 +235,8 @@ This queuing behavior allows shards to unload chunks more quickly in
235235
cases of heavily imbalanced cluster, such as when performing initial
236236
data loads without pre-splitting and when adding new shards.
237237

238-
This behavior also affects the :dbcommand:`moveChunk` command, and
239-
migration scripts that use the :dbcommand:`moveChunk` command may
238+
This behavior also affects the :dbcommand:`moveRange` command, and
239+
migration scripts that use the :dbcommand:`moveRange` command may
240240
proceed more quickly.
241241

242242
In some cases, the delete phases may persist longer. Starting in MongoDB
@@ -245,7 +245,7 @@ a failover during the delete phase. Orphaned documents are cleaned up
245245
even if a replica set's primary crashes or restarts during this phase.
246246

247247
The ``_waitForDelete``, available as a setting for the balancer as well
248-
as the :dbcommand:`moveChunk` command, can alter the behavior so that
248+
as the :dbcommand:`moveRange` command, can alter the behavior so that
249249
the delete phase of the current migration blocks the start of the next
250250
chunk migration. The ``_waitForDelete`` is generally for internal
251251
testing purposes. For more information, see

source/core/sharding-data-partitioning.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ chunks across shards. See :ref:`sharding-internals-balancing` for more
159159
details on balancing chunks across shards.
160160

161161
.. _sharding-chunk-migration:
162+
.. _sharding-range-migration:
162163

163164
Chunk Migration
164165
---------------
Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
=========
2+
moveRange
3+
=========
4+
5+
.. default-domain:: mongodb
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 1
11+
:class: singlecol
12+
13+
Definition
14+
----------
15+
16+
.. dbcommand:: moveRange
17+
18+
Moves :term:`ranges <range>` between :term:`shards <shard>`. Run
19+
the :dbcommand:`moveRange` command with a :binary:`~bin.mongos`
20+
instance while using the :term:`admin database`.
21+
22+
Syntax
23+
------
24+
25+
The command has the following syntax:
26+
27+
.. code-block:: javascript
28+
29+
db.adminCommand(
30+
{
31+
toShard: <ID of the recipient shard>,
32+
min: <min key of the range to move>,
33+
max: <max key of the range to move>, // optional
34+
forceJumbo: <bool>, // optional
35+
waitForDelete: <bool>, // optional
36+
writeConcern: <write concern>, // optional
37+
secondaryThrottle: <bool> // optional
38+
}
39+
)
40+
41+
Command Fields
42+
--------------
43+
44+
The command takes the following fields:
45+
46+
.. list-table::
47+
:header-rows: 1
48+
:widths: 20 20 80
49+
50+
* - Field
51+
- Type
52+
- Description
53+
54+
* - ``toShard``
55+
- string
56+
- ID of the recipient shard.
57+
58+
* - ``min``
59+
- key
60+
- Minimum key of the range to move.
61+
62+
* - ``max``
63+
- key
64+
- Optional.
65+
66+
Maximum key of the range to move. If you do not specify
67+
``max``, given a chunk ``C`` including the shard key ``min``,
68+
``max`` is determined in the following way:
69+
70+
- If the data size of the range between ``min`` and ``max(C)``
71+
is less than the per-collection chunk size or the default
72+
chunk size, the chunk's max is selected as
73+
``max`` = ``max(C)``.
74+
75+
- Otherwise, key ``max`` < ``max(C)`` where ``max`` depends
76+
on the configured chunk size.
77+
78+
* - :ref:`forceJumbo <moverange-forceJumbo>`
79+
- boolean
80+
- .. _moverange-forceJumbo:
81+
82+
Optional.
83+
84+
Flag that determines if the command can move a range that is
85+
:ref:`too large to migrate <migration-chunk-size-limit>`. The
86+
range may or may not be labeled as :ref:`jumbo <jumbo-chunk>`.
87+
88+
- If ``true``, the command can move the range.
89+
- If ``false``, the command cannot move the range.
90+
91+
The default is ``false``.
92+
93+
* - ``writeConcern``
94+
- document
95+
- Optional.
96+
97+
Document with the :ref:`write concern <write-concern>`.
98+
99+
The default is :writeconcern:`w: majority <"majority">`.
100+
101+
* - ``secondaryThrottle``
102+
- boolean
103+
- Optional.
104+
105+
- If ``true``, each document move during chunk migration
106+
propagates to at least one secondary before the balancer
107+
proceeds with the next document. This is equivalent to a write
108+
concern of :writeconcern:`{ w: 2 } <\<number\>>`.
109+
110+
Use the ``writeConcern`` option to specify a different write
111+
concern.
112+
113+
- If ``false``, the balancer does not wait for replication to a
114+
secondary and instead continues with the next document.
115+
116+
For more information, see
117+
:ref:`sharded-cluster-config-secondary-throttle`.
118+
119+
The :ref:`range migration <sharding-chunk-migration>` section
120+
describes how ranges move between shards on MongoDB.
121+
122+
Considerations
123+
--------------
124+
125+
Only use the :dbcommand:`moveRange` in scenarios like:
126+
127+
- an initial ingestion of data
128+
- a large bulk import operation
129+
130+
Allow the balancer to create and balance ranges in sharded clusters in
131+
most cases.
132+
133+
.. seealso::
134+
135+
:ref:`<create-chunks-in-a-sharded-cluster>`
136+
137+
Examples
138+
--------
139+
140+
The following examples use a collection with:
141+
142+
- Shard key ``x``
143+
- Configured chunk size of 128MB
144+
- A chunk with boundaries: ``[x: 0, x: 100)``
145+
146+
Specify both ``min`` and ``max``
147+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
148+
149+
The following table lists the results of setting ``min`` and ``max``
150+
to various values:
151+
152+
.. list-table::
153+
:header-rows: 1
154+
:widths: 20 20 80
155+
156+
* - ``min``
157+
- ``max``
158+
- Result
159+
160+
* - ``0``
161+
- ``100``
162+
- Moves all the documents in the range to the recipient shard.
163+
164+
* - ``10``
165+
- ``30``
166+
- Creates three sub-ranges:
167+
168+
- ``[x: 0, x: 10)``
169+
- ``[x: 10, x: 30)``
170+
- ``[x: 30, x: 100)``
171+
172+
Moves all the documents in ``[x: 10, x: 30)`` to the recipient
173+
shard.
174+
175+
* - ``0``
176+
- ``20``
177+
- Creates two sub-ranges:
178+
179+
- ``[x: 0, x: 20)``
180+
- ``[x: 20, x: 100)``
181+
182+
Moves all the documents in ``[x: 0, x: 20)`` to the recipient
183+
shard.
184+
185+
* - ``40``
186+
- ``100``
187+
- Creates two sub-ranges:
188+
189+
- ``[x: 0, x: 40)``
190+
- ``[x: 40, x: 100)``
191+
192+
Moves all the documents in ``[x: 40, x: 100)`` to the recipient
193+
shard.
194+
195+
Specify ``min`` but not ``max``
196+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
197+
198+
The following table lists the results of setting ``min`` to various
199+
values:
200+
201+
.. list-table::
202+
:header-rows: 1
203+
:widths: 20 20 80
204+
205+
* - ``min``
206+
- Amount of Data in Key Range
207+
- Result
208+
209+
* - ``0``
210+
- Less than 128 MB contained between keys ``x: 0`` and ``x: 100``.
211+
- Moves all the documents in the range to the recipient shard.
212+
213+
* - ``10``
214+
- Less than 128 MB contained between keys ``x: 0`` and ``x: 100``.
215+
- Creates two sub-ranges:
216+
217+
- ``[x: 0, x: 10)``
218+
- ``[x : 10, x: 100)``
219+
220+
Moves all documents in ``[x: 10, x: 100)`` to the recipient
221+
shard.
222+
223+
* - ``10``
224+
- 128 MB contained between keys ``x: 10`` and ``x: 30``.
225+
- Creates three sub-ranges:
226+
227+
- ``[x: 0, x: 10)``
228+
- ``[x: 10, x: 30)``
229+
- ``[x: 30, x: 100)``
230+
231+
Moves all documents in ``[x: 10, x: 30)`` to the recipient
232+
shard.
233+
234+
.. admin-only

source/reference/command/nav-sharding.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Sharding Commands
113113
* - :dbcommand:`medianKey`
114114

115115
- Deprecated internal command. See :dbcommand:`splitVector`.
116-
116+
117117
* - :dbcommand:`moveChunk`
118118

119119
- Internal command that migrates chunks between shards.
@@ -122,6 +122,10 @@ Sharding Commands
122122

123123
- Reassigns the :term:`primary shard` when removing a shard from a sharded cluster.
124124

125+
* - :dbcommand:`moveRange`
126+
127+
- Migrates ranges between shards.
128+
125129
* - :dbcommand:`mergeChunks`
126130

127131
- Provides the ability to combine chunks on a single shard.
@@ -210,6 +214,7 @@ Sharding Commands
210214
/reference/command/medianKey
211215
/reference/command/moveChunk
212216
/reference/command/movePrimary
217+
/reference/command/moveRange
213218
/reference/command/mergeChunks
214219
/reference/command/refineCollectionShardKey
215220
/reference/command/removeShard

source/reference/command/serverStatus.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4284,10 +4284,10 @@ shardingStatistics
42844284
.. serverstatus:: shardingStatistics.countDonorMoveChunkStarted
42854285

42864286
The total number of times that the :dbcommand:`moveChunk` command
4287-
has started on the shard, of which this node is a member, as part of
4288-
a :ref:`chunk migration process <chunk-migration-procedure>`. This
4289-
increasing number does not consider whether the chunk migrations
4290-
succeed or not.
4287+
or :dbcommand:`moveRange` have started on the shard, of which this
4288+
node is a member, as part of a :ref:`chunk migration process
4289+
<chunk-migration-procedure>`. This increasing number does not
4290+
consider whether the chunk migrations succeed or not.
42914291

42924292
*Only present when run on a shard.*
42934293

@@ -4297,9 +4297,10 @@ shardingStatistics
42974297
of the chunk migrations <chunk-migration-procedure>` from this
42984298
shard, of which this node is a member. Specifically, for each
42994299
migration from this shard, the tracked time starts with the
4300-
:dbcommand:`moveChunk` command and ends before the destination shard
4301-
enters a catch-up phase to apply changes that occurred during the
4302-
:ref:`chunk migrations <chunk-migration-procedure>`.
4300+
:dbcommand:`moveRange` and :dbcommand:`moveChunk` commands and ends
4301+
before the destination shard enters a ``catchup`` phase to apply
4302+
changes that occurred during the :ref:`chunk migrations
4303+
<chunk-migration-procedure>`.
43034304

43044305
*Only present when run on a shard.*
43054306

source/reference/command/split.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ this purpose.
132132
.. seealso::
133133

134134
- :dbcommand:`moveChunk`
135+
- :dbcommand:`moveRange`
135136
- :method:`sh.moveChunk()`
136137
- :method:`sh.splitAt()`
137138
- :method:`sh.splitFind()`

source/reference/glossary.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,15 @@ Glossary
874874

875875
.. include:: /includes/extracts/4.2-changes-query-shapes.rst
876876

877+
range
878+
A contiguous range of :term:`shard key` values within a
879+
chunk. Data ranges include the lower boundary and
880+
exclude the upper boundary. MongoDB migrates data when a
881+
shard contains :ref:`too much data of a collection
882+
<sharding-migration-thresholds>` relative to other shards.
883+
See :ref:`sharding-data-partitioning` and
884+
:ref:`sharding-balancing`.
885+
877886
read concern
878887
Specifies a level of isolation for read operations. For example,
879888
you can use read concern to only read data that has propagated to

source/reference/parameters.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3202,10 +3202,10 @@ Sharding Parameters
32023202

32033203
|mongod-only|
32043204

3205-
For :dbcommand:`moveChunk` operations, specifies the maximum
3206-
percentage of untrasferred data allowed by the migration protocol
3207-
(expressed in percentage of the total chunk size) to
3208-
transition from the ``catchup`` phase to the ``commit`` phase.
3205+
For :dbcommand:`moveChunk` and :dbcommand:`moveRange` operations,
3206+
specifies the maximum percentage of untrasferred data allowed by the
3207+
migration protocol (expressed in percentage of the total chunk size)
3208+
to transition from the ``catchup`` phase to the ``commit`` phase.
32093209

32103210
Setting a higher catchup percentage can decrease the amount of time
32113211
it takes for the migration to complete at the cost of increased

source/tutorial/create-chunks-in-sharded-cluster.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _create-chunks-in-a-sharded-cluster:
2+
13
==================================
24
Create Chunks in a Sharded Cluster
35
==================================

0 commit comments

Comments
 (0)