-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
moveChunk.txt
242 lines (149 loc) · 6.79 KB
/
moveChunk.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
=========
moveChunk
=========
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. dbcommand:: moveChunk
Internal administrative command. Moves :term:`chunks <chunk>` between
:term:`shards <shard>`. Issue the :dbcommand:`moveChunk` command via
a :binary:`~bin.mongos` instance while using the :term:`admin database`.
Use the following forms:
.. |method| replace:: :method:`sh.moveChunk`
helper method
.. include:: /includes/fact-dbcommand-tip
.. code-block:: javascript
db.adminCommand( { moveChunk : <namespace> ,
find : <query> ,
to : <string>,
forceJumbo: <boolean>,
_secondaryThrottle : <boolean>,
writeConcern: <document>,
_waitForDelete : <boolean> } )
Alternatively:
.. code-block:: javascript
db.adminCommand( { moveChunk : <namespace> ,
bounds : <array> ,
to : <string>,
forceJumbo: <boolean>,
_secondaryThrottle : <boolean>,
writeConcern: <document>,
_waitForDelete : <boolean> } )
The :dbcommand:`moveChunk` command has the following fields:
.. list-table::
:header-rows: 1
:widths: 20 20 80
* - Field
- Type
- Description
* - ``moveChunk``
- string
- The :term:`namespace` of the :term:`collection` where the
:term:`chunk` exists. Specify the collection's full namespace,
including the database name.
* - ``find``
- document
- An equality match on the shard key that specifies the shard-key value
of the chunk to move. Specify either the ``bounds`` field or the
``find`` field but not both. Do **not** use the ``find`` field to
select chunks in collections that use a :term:`hashed shard key`.
* - ``bounds``
- array
- The bounds of a specific chunk to move. The array must consist of two
documents that specify the lower and upper shard key values of a chunk
to move. Specify either the ``bounds`` field or the ``find`` field but
not both. Use ``bounds`` to select chunks in collections that use a
:term:`hashed shard key`.
* - ``to``
- string
- The name of the destination shard for the chunk.
* - :ref:`forceJumbo <movechunk-forceJumbo>`
- boolean
- .. _movechunk-forceJumbo:
Optional. A flag that determines if the command can move a
chunk that is :ref:`too large to migrate
<migration-chunk-size-limit>`. The chunk may or may not be
labeled as :ref:`jumbo <jumbo-chunk>`.
- If ``true``, the command can move the chunk.
- If ``false``, the command cannot move the chunk.
The default is ``false``.
.. |cmd| replace:: ``moveChunk``
.. include:: /includes/fact-forceJumbo
* - ``_secondaryThrottle``
- boolean
- Optional. Starting in MongoDB 3.4, for :ref:`WiredTiger <storage-wiredtiger>`,
defaults to ``false``.
- If ``true``, then by default, each document move during chunk
migration propagates to at least one secondary before the balancer
proceeds with the next document. This is equivalent to a write
concern of :writeconcern:`{ w: 2 } <\<number\>>`.
Use the ``writeConcern`` option to specify a different write concern.
- If ``false``, the balancer does not wait for replication to a
secondary and instead continues with the next document.
For more information, see
:ref:`sharded-cluster-config-secondary-throttle`.
* - ``writeConcern``
- document
- Optional. A document that expresses the :doc:`write concern
</reference/write-concern>` that the ``_secondaryThrottle`` will use to
wait for secondaries during the chunk migration.
``writeConcern`` requires ``_secondaryThrottle: true``.
* - ``_waitForDelete``
- boolean
- Optional. Internal option for testing purposes. The default is ``false``. If set
to ``true``, the delete phase of a :dbcommand:`moveChunk` operation
blocks.
The value of ``bounds`` takes the form:
.. code-block:: javascript
[ { hashedField : <minValue> } ,
{ hashedField : <maxValue> } ]
The :ref:`chunk migration <sharding-chunk-migration>` section
describes how chunks move between shards on MongoDB.
.. seealso::
- :dbcommand:`split`
- :method:`sh.moveChunk()`
- :method:`sh.splitAt()`
- :method:`sh.splitFind()`
Compatibility
-------------
This command is available in deployments hosted in the following environments:
.. include:: /includes/fact-environments-atlas-only.rst
.. include:: /includes/fact-environments-atlas-support-no-serverless.rst
.. include:: /includes/fact-environments-onprem-only.rst
Considerations
--------------
Only use the :dbcommand:`moveChunk` in special circumstances
such as preparing your :term:`sharded cluster` for an initial
ingestion of data, or a large bulk import operation. In most cases
allow the balancer to create and balance chunks in sharded clusters.
See :doc:`/tutorial/create-chunks-in-sharded-cluster` for more information.
Behavior
--------
Indexes
~~~~~~~
:dbcommand:`moveChunk` requires that all indexes exist on the
target (i.e. ``to`` ) shard before migration and returns an error if a
required index does not exist.
Meta Data Error
~~~~~~~~~~~~~~~
:dbcommand:`moveChunk` returns the following error message if another
metadata operation is in progress on the :data:`~config.chunks` collection:
.. code-block:: none
errmsg: "The collection's metadata lock is already taken."
If another process, such as a balancer process, changes meta data
while :dbcommand:`moveChunk` is running, you may see this
error. You may retry the :dbcommand:`moveChunk` operation without
side effects.
``maxCatchUpPercentageBeforeBlockingWrites`` Server Parameter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Starting in MongoDB 5.0, you can set the
:parameter:`maxCatchUpPercentageBeforeBlockingWrites` to specify the
maximum allowed percentage of data not yet migrated
during a :dbcommand:`moveChunk` operation when compared to the
total size (in MBs) of the chunk being transferred.
.. admin-only