Skip to content

Commit b4f6334

Browse files
authored
DOCSP-46644: Stop balancer on a per-collection basis (#670)
* commit * small * feedback * error * feedback * feedback and restructure * tweaks * little tweak * feedback * remove step * feedback
1 parent 9063541 commit b4f6334

File tree

3 files changed

+98
-16
lines changed

3 files changed

+98
-16
lines changed
Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,31 @@
11
.. important::
22

3-
When the source or destination cluster is a sharded cluster, you must stop
4-
the balancer on both clusters and not run the :dbcommand:`moveChunk` or
5-
:dbcommand:`moveRange` commands for the duration of the migration. To stop
6-
the balancer, run the :dbcommand:`balancerStop` command and wait for the
7-
command to complete.
3+
You must always disable the balancer on a sharded destination
4+
cluster by using :dbcommand:`balancerStop`.
5+
After stopping the balancer, wait **fifteen minutes** before
6+
starting ``mongosync``. This gives the cluster time to
7+
finish any in-progress chunk migrations.
8+
9+
If the source or destination cluster is a sharded cluster
10+
and you are not running ``mongosync`` with :ref:`namespace
11+
filtering <c2c-filtered-sync>`,
12+
you must disable the source cluster's balancer
13+
by running the :dbcommand:`balancerStop` command and waiting 15 minutes
14+
for the command to complete.
15+
16+
If the source or destination cluster is a sharded cluster and you
17+
are running ``mongosync`` with namespace filtering, you can
18+
globally enable the source cluster's
19+
balancer but you must disable it for
20+
all collections within the namespace filter.
21+
See :ref:`disabling-balancer-filtered`. You can also fully disable
22+
the source cluster's balancer.
23+
24+
During migration, do not run the :dbcommand:`moveChunk` or
25+
:dbcommand:`moveRange` commands. If you have enabled the source cluster's
26+
balancer, but disabled it for collections within the namespace
27+
filter, do not run :dbcommand:`shardCollection` on collections
28+
within the namespace filter. If you run :dbcommand:`shardCollection` on
29+
collections within the namespace filter during the migration, ``mongosync``
30+
returns an error and stops, which requires you to start the migration
31+
from scratch.

source/reference/limitations.txt

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,31 @@ Sharded Clusters
124124
To check for index inconsistencies, see :ref:`Find Inconsistent
125125
Indexes Across Shards <manage-indexes-find-inconsistent-indexes>`.
126126

127-
- You must stop the balancer on sharded source and destination clusters
128-
for the entire lifetime of a migration. To stop the balancer, run the
129-
:dbcommand:`balancerStop` command and wait for the command to
130-
complete.
131-
132-
.. note::
133-
134-
After stopping the balancer, wait fifteen minutes before
135-
starting ``mongosync``. This gives the cluster time to
136-
finish any in progress chunk migrations.
127+
- If the source or destination cluster is a sharded cluster
128+
and you are not running ``mongosync`` with :ref:`namespace
129+
filtering <c2c-filtered-sync>`,
130+
you must disable the source cluster's balancer
131+
by running the :dbcommand:`balancerStop` command and waiting 15 minutes
132+
for the command to complete.
133+
134+
If the source or destination cluster is a sharded cluster and you
135+
are running ``mongosync`` with namespace filtering, you can
136+
globally enable the source cluster's
137+
balancer but you must disable it for
138+
all collections within the namespace filter.
139+
See :ref:`disabling-balancer-filtered`. You can also fully disable
140+
the source cluster's balancer.
141+
142+
You must always disable the balancer on a sharded destination
143+
cluster by using :dbcommand:`balancerStop`.
144+
145+
- If you have enabled the source cluster's
146+
balancer, but disabled it for collections within the namespace
147+
filter, do not run :dbcommand:`shardCollection` on collections
148+
within the namespace filter. If you run :dbcommand:`shardCollection` on
149+
collections within the namespace filter during the migration, ``mongosync``
150+
returns an error and stops, which requires you to start the migration
151+
from scratch.
137152

138153
- You must not run the :dbcommand:`moveChunk` and
139154
:dbcommand:`moveRange` commands on the source or destination clusters.

source/reference/mongosync/mongosync-behavior.txt

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,49 @@ preserve the source cluster's sharding configuration.
102102

103103
.. include:: /includes/fact-mongosync-balancer.rst
104104

105+
.. _disabling-balancer-filtered:
106+
107+
Disabling Balancer for Collections in Filtered Sync
108+
'''''''''''''''''''''''''''''''''''''''''''''''''''
109+
110+
If you are using a :ref:`namespace filter <c2c-filtered-sync>`
111+
and want to enable your source cluster's balancer for
112+
collections outside the namespace filter,
113+
follow these instructions before
114+
you start ``mongosync``.
115+
116+
.. procedure::
117+
:style: normal
118+
119+
.. step:: Enable the balancer for the source cluster.
120+
121+
Before starting ``mongosync`` with a :ref:`namespace filter
122+
<c2c-filtered-sync>`, enable the balancer for the source cluster
123+
by running the :method:`sh.startBalancer()` method in ``mongosh``.
124+
125+
.. step:: Disable the balancer for each collection.
126+
127+
Disable the balancer for each collection within the
128+
namespace filter by running the :dbcommand:`setAllowMigrations` command:
129+
130+
.. code-block:: javascript
131+
132+
db.adminCommand(
133+
{
134+
setAllowMigrations: “<db>.<collection>”,
135+
allowMigrations: false
136+
}
137+
)
138+
139+
Run the preceding command for every collection within the
140+
namespace filter.
141+
142+
.. important::
143+
144+
If you enable the source cluster's balancer but do not use a
145+
namespace filter, or if you do not disable the balancer for all
146+
collections within the namespace filter, ``mongosync`` fails.
147+
105148
Pre-Split Chunks
106149
''''''''''''''''
107150

@@ -131,7 +174,7 @@ primary shard to each database by means of a round-robin.
131174

132175
.. warning::
133176

134-
Running :dbcommand:`movePrimary` on the source or desintation cluster
177+
Running :dbcommand:`movePrimary` on the source or destination cluster
135178
during migration may result in a fatal error or require you to
136179
restart the migration from the start. For more information, see
137180
:ref:`c2c-sharded-limitations`.

0 commit comments

Comments
 (0)