Skip to content

Commit 2e8419e

Browse files
committed
DOCSP-7707 remove manual flushRouterConfig for most cases
1 parent bab1627 commit 2e8419e

File tree

6 files changed

+146
-103
lines changed

6 files changed

+146
-103
lines changed
Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
.. warning::
2-
3-
Starting in MongoDB 4.2:
4-
If you drop a database and create a new database with the same name, you
5-
must either:
6-
7-
- Restart all :binary:`~bin.mongos` instances and all
8-
:binary:`~bin.mongod` shard members (including the secondary
9-
members);
10-
11-
- Use the :dbcommand:`flushRouterConfig` command on all
12-
:binary:`~bin.mongos` instances and all :binary:`~bin.mongod`
13-
shard members (including the secondary members) before reading
14-
or writing to that database.
15-
16-
This ensures that the :binary:`~bin.mongos` and shard instances
17-
refresh their metadata cache, including the location of the
18-
:ref:`primary shard <primary-shard>` for the new database.
19-
20-
Otherwise, the you may miss data on reads, and may not write data to
21-
the correct shard. To recover, you must manually intervene.
22-
23-
In MongoDB 4.0 and earlier:
24-
If you drop a database and create a new database with the same name, you
25-
must either restart all :binary:`~bin.mongos` instances, or use the
26-
:dbcommand:`flushRouterConfig` command on all :binary:`~bin.mongos`
27-
instances before reading or writing to that database. This
28-
ensures that the :binary:`~bin.mongos` instances refresh their
29-
metadata cache, including the location of the :ref:`primary shard
30-
<primary-shard>` for the new database.
31-
32-
Otherwise, the you may miss data on reads, and may not write data to
33-
the correct shard. To recover, you must manually intervene.
34-
1+
For MongoDB 4.2 and previous, when executing the
2+
:dbcommand:`dropDatabase` command, you must perform the following
3+
additional steps if you intend to create a new database with the same
4+
name as the dropped database.
5+
6+
.. note::
7+
8+
MongoDB 4.4 does not require these additional steps when dropping and
9+
recreating a database with the same name.
10+
11+
- For **MongoDB 4.2**, you must either:
12+
13+
- Restart all :binary:`~bin.mongos` instances and all
14+
:binary:`~bin.mongod` shard members (including the secondary
15+
members);
16+
17+
- Use the :dbcommand:`flushRouterConfig` command on all
18+
:binary:`~bin.mongos` instances and all :binary:`~bin.mongod`
19+
shard members (including the secondary members) before reading
20+
or writing to that database.
21+
22+
- For **MongoDB 4.0 and earlier**, you must either:
23+
24+
- Restart all :binary:`~bin.mongos` instances;
25+
26+
- Use the :dbcommand:`flushRouterConfig` command on all
27+
:binary:`~bin.mongos` instances before reading or writing to that
28+
database.
29+
30+
These steps ensure that all cluster nodes refresh their metadata cache,
31+
which includes the location of the :ref:`primary shard<primary-shard>`
32+
for the new database. Otherwise, you may miss data on reads, and may not
33+
write data to the correct shard. To recover, you must manually
34+
intervene.
Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
1-
.. warning::
2-
3-
4-
Starting in MongoDB 4.2:
5-
If you use the :dbcommand:`movePrimary` command to move
6-
*unsharded* collections, you must either:
7-
8-
- Restart all :binary:`~bin.mongos` instances **and** all
9-
:binary:`~bin.mongod` shard members (including the secondary
10-
members);
11-
12-
- Use the :dbcommand:`flushRouterConfig` command on all
13-
:binary:`~bin.mongos` instances and all :binary:`~bin.mongod`
14-
shard members (including the secondary members) before reading
15-
or writing any data to any *unsharded* collections that were
16-
moved.
17-
18-
Otherwise, you may miss data on reads, and may not write data to
19-
the correct shard. To recover, you must manually intervene.
20-
21-
In MongoDB 4.0 and earlier:
22-
If you use the :dbcommand:`movePrimary` command to move
23-
*unsharded* collections, you must either:
24-
25-
- Restart all :binary:`~bin.mongos` instances;
26-
27-
- Use the :dbcommand:`flushRouterConfig` command on all
28-
:binary:`~bin.mongos` instances before reading or writing any
29-
data to any unsharded collections that were moved.
30-
31-
Otherwise, you may miss data on reads, and may not write data to
32-
the correct shard. To recover, you must manually intervene.
1+
For MongoDB 4.2 and previous, if using the :dbcommand:`movePrimary`
2+
command on a database that contains an *unsharded* collection, you
3+
must perform the following additional steps.
4+
5+
.. note::
6+
7+
MongoDB 4.4 does not require these additional steps when moving
8+
databases that contain unsharded collections.
9+
10+
- For **MongoDB 4.2**, you must either:
11+
12+
- Restart all :binary:`~bin.mongos` instances **and** all
13+
:binary:`~bin.mongod` shard members (including the secondary
14+
members);
15+
16+
- Use the :dbcommand:`flushRouterConfig` command on all
17+
:binary:`~bin.mongos` instances and all :binary:`~bin.mongod`
18+
shard members (including the secondary members) before reading
19+
or writing any data to any unsharded collections that were
20+
moved.
21+
22+
- For **MongoDB 4.0 and earlier**, you must either:
23+
24+
- Restart all :binary:`~bin.mongos` instances;
25+
26+
- Use the :dbcommand:`flushRouterConfig` command on all
27+
:binary:`~bin.mongos` instances before reading or writing any data
28+
to any unsharded collections that were moved.
29+
30+
These steps ensure that all cluster nodes refresh their metadata cache,
31+
which includes the location of the :ref:`primary shard<primary-shard>`.
32+
Otherwise, you may miss data on reads, and may not write data to the
33+
correct shard. To recover, you must manually intervene.

source/reference/command/flushRouterConfig.txt

Lines changed: 63 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,60 +10,88 @@ flushRouterConfig
1010
:depth: 1
1111
:class: singlecol
1212

13+
Definition
14+
----------
15+
1316
.. dbcommand:: flushRouterConfig
1417

15-
:dbcommand:`flushRouterConfig` clears the cached routing table. Use
16-
this command to force a refresh of the routing table cache. In most
17-
cases, this happens automatically. You should only need to run
18-
:dbcommand:`flushRouterConfig` after :dbcommand:`movePrimary` has
19-
been run or after manually clearing the ``jumbo`` chunk flag.
18+
:dbcommand:`flushRouterConfig` marks the cached routing table for a
19+
sharded cluster as stale, causing the next operation that requests
20+
the routing table to refresh the cache. Management of the routing
21+
table cache is generally handled automatically by the cluster. You
22+
should only need to run the :dbcommand:`flushRouterConfig` command
23+
manually in specific instances, as indicated under
24+
:ref:`flushrouterconfig-considerations`.
25+
26+
.. note::
27+
28+
**Starting in MongoDB 4.4,** running :dbcommand:`flushRouterConfig`
29+
is no longer required after executing the :dbcommand:`movePrimary` or
30+
:dbcommand:`dropDatabase` commands. These two commands now
31+
automatically refresh a sharded cluster's routing table as needed
32+
when run.
33+
34+
Syntax
35+
------
36+
37+
Starting in MongoDB 4.0.6 (and 3.6.11), the
38+
:dbcommand:`flushRouterConfig` is available on both
39+
:binary:`~bin.mongos` and :binary:`~bin.mongod` instances, and has the
40+
following syntax:
41+
42+
- Flush the cache for a specified collection when passed in a
43+
collection namespace parameter:
2044

21-
- **Starting in MongoDB 4.0.6 (and 3.6.11),**
22-
:dbcommand:`flushRouterConfig` is available on both
23-
:binary:`~bin.mongos` instances and :binary:`~bin.mongod`
24-
instances and can:
45+
.. code-block:: javascript
2546

26-
- Flush the cache for a specified collection when passed in a
27-
collection namespace parameter:
47+
db.adminCommand({ flushRouterConfig: "<db.collection>" } )
2848

29-
.. code-block:: javascript
49+
- Flush the cache for a specified database and all of its collections
50+
when passed in a database namespace parameter:
3051

31-
db.adminCommand({ flushRouterConfig: "<db.collection>" } )
52+
.. code-block:: javascript
3253

33-
- Flush the cache for a specified database and its collections
34-
when passed in a database namespace parameter:
54+
db.adminCommand({ flushRouterConfig: "<db>" } )
3555

36-
.. code-block:: javascript
56+
- Flush the cache for all databases and their collections when run
57+
without a parameter or passed in a non-string scalar value
58+
(e.g. ``1``):
3759

38-
db.adminCommand({ flushRouterConfig: "<db>" } )
60+
.. code-block:: javascript
3961

40-
- Flush the cache for all databases and their collections when run
41-
without a parameter or passed in a non-string scalar value (e.g. ``1``):
62+
db.adminCommand("flushRouterConfig")
63+
db.adminCommand( { flushRouterConfig: 1 } )
4264

43-
.. code-block:: javascript
65+
.. note::
4466

45-
db.adminCommand("flushRouterConfig")
46-
db.adminCommand( { flushRouterConfig: 1 } )
67+
**In MongoDB 4.0.5 and earlier (and 3.6.10 and earlier)**,
68+
:dbcommand:`flushRouterConfig` is only available for
69+
:binary:`~bin.mongos` instances and can only flush the cache for all
70+
databases and their collections:
4771

48-
- **In MongoDB 4.0.5 and earlier (and 3.6.10 and earlier)**,
49-
:dbcommand:`flushRouterConfig` is only available for
50-
:binary:`~bin.mongos` instances and can flush the cache for all
51-
databases and their collections:
72+
.. code-block:: javascript
5273

53-
.. code-block:: javascript
74+
db.adminCommand("flushRouterConfig")
75+
db.adminCommand( { flushRouterConfig: 1 } )
5476

55-
db.adminCommand("flushRouterConfig")
56-
db.adminCommand( { flushRouterConfig: 1 } )
77+
.. _flushrouterconfig-considerations:
5778

5879
Considerations
5980
--------------
6081

61-
You should only need to run :dbcommand:`flushRouterConfig` after
62-
:dbcommand:`movePrimary` has been run or after manually clearing the
63-
``jumbo`` chunk flag.
82+
Generally, a sharded cluster's routing table is automatically refreshed
83+
as needed as part of normal operation. However, you should manually
84+
issue the :dbcommand:`flushRouterConfig` command in the following
85+
instances:
6486

65-
.. seealso::
87+
- If running MongoDB 4.2 or earlier, after executing the
88+
:dbcommand:`movePrimary` or :dbcommand:`dropDatabase` commands.
6689

67-
- :ref:`movePrimary Considerations <movePrimary-consideration>`
90+
- If running MongoDB 4.2.2 or earlier (or 4.0.14 or earlier), after
91+
manually clearing the ``jumbo`` flag from a chunk that could not be
92+
split (i.e. an *indivisible chunk*). See
93+
:doc:`/tutorial/clear-jumbo-flag` for more information.
6894

69-
- :doc:`/tutorial/clear-jumbo-flag`
95+
- Before running the :method:`db.collection.getShardDistribution()`
96+
command. This ensures that the command returns the most up-to-date
97+
information.

source/release-notes/4.4.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,17 @@ MongoDB 4.4 adds the following parameters for controlling this behavior:
536536
to the :binary:`~bin.mongos` are allowed regardless of established
537537
connection pool size.
538538

539+
Improved Routing Table Updates
540+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
541+
542+
Running :dbcommand:`flushRouterConfig` is no longer required after
543+
executing the :dbcommand:`movePrimary` or :dbcommand:`dropDatabase`
544+
commands. These two commands now automatically refresh a sharded
545+
cluster's routing table as needed when run. Manually issuing the
546+
:dbcommand:`flushRouterConfig` command is still recommended in the cases
547+
described under
548+
:ref:`flushRouterConfig Considerations<flushrouterconfig-considerations>`.
549+
539550
General Sharded Clusters Improvements
540551
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
541552

source/tutorial/clear-jumbo-flag.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ You can manually clear the flag using the following steps.
7878

7979
.. tabs::
8080

81-
.. tab:: For MongoDB v4.2.3+ (4.0.15+)
81+
.. tab:: MongoDB 4.2.3 and later (4.0.15 and later)
8282
:tabid: clear-flag-command
8383

8484
Starting in version 4.2.3 and 4.0.15, MongoDB provides the
@@ -93,7 +93,7 @@ You can manually clear the flag using the following steps.
9393
.. include:: /includes/steps/clear-jumbo-flag-command.rst
9494

9595

96-
.. tab:: For MongoDB v4.2.2 and earlier (4.0.14 and earlier)
96+
.. tab:: MongoDB 4.2.2 and earlier (4.0.14 and earlier)
9797
:tabid: clear-flag-manual
9898

9999

source/tutorial/remove-shards-from-cluster.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@ resemble the following:
246246
}
247247
}
248248

249+
Using ``movePrimary`` To Move Unsharded Collections
250+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
251+
249252
.. include:: /includes/warning-movePrimary.rst
250253

251254
.. _remove-shard-finalize-migration:

0 commit comments

Comments
 (0)