Skip to content

Commit b969895

Browse files
authored
DOCS-15799 removing dropDatabase context for SharedClusters (#2310)
* DOCS-15799 removing dropDatabase context for SharedClusters * add 5.0 section * external feedback 1 * remove 4.0 content * remove 4.0 content
1 parent a0f1935 commit b969895

File tree

1 file changed

+6
-49
lines changed

1 file changed

+6
-49
lines changed

source/includes/warning-dropDatabase-shardedCluster.rst

Lines changed: 6 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ If you intend to create a new database with the same name as the dropped
22
database, you must follow these additional steps for using the
33
:dbcommand:`dropDatabase` command, specific to your version of MongoDB:
44

5-
- For **MongoDB 4.4 and later**, you must:
5+
- For **MongoDB 5.0 and later**, you must:
6+
7+
#. Run the :dbcommand:`dropDatabase` command on a
8+
:binary:`~bin.mongos`, no additional steps required.
9+
10+
- For **MongoDB 4.4**, you must:
611

712
#. Run the :dbcommand:`dropDatabase` command on a
813
:binary:`~bin.mongos`.
@@ -24,54 +29,6 @@ database, you must follow these additional steps for using the
2429
:binary:`~bin.mongos` instances before reading or writing to that
2530
database.
2631

27-
- For **MongoDB 4.0 and earlier**, you must:
28-
29-
#. Run the :dbcommand:`dropDatabase` command on a
30-
:binary:`~bin.mongos`.
31-
32-
#. Connect to each shard's :term:`primary` and verify that the
33-
namespace has been dropped. If it has not, rerun the
34-
:dbcommand:`dropDatabase` command again directly from the
35-
:term:`primary`.
36-
37-
#. Connect to a :binary:`~bin.mongos`, switch to the
38-
:term:`config database`, and remove any reference to the removed
39-
namespace from the ``databases``, ``collections``, ``chunks``,
40-
``tags``, and ``locks`` collections:
41-
42-
.. code-block:: javascript
43-
44-
use config
45-
db.collections.remove( { _id: /^DATABASE\./ }, {writeConcern: {w: 'majority' }} )
46-
db.databases.remove( { _id: "DATABASE" }, {writeConcern: {w: 'majority' }} )
47-
db.chunks.remove( { ns: /^DATABASE\./ }, {writeConcern: {w: 'majority' }} )
48-
db.tags.remove( { ns: /^DATABASE\./ }, {writeConcern: {w: 'majority' }} )
49-
db.locks.remove( { _id: /^DATABASE\./ }, {writeConcern: {w: 'majority' }} )
50-
51-
Where ``DATABASE`` represents the namespace of the database you
52-
just dropped.
53-
54-
#. Connect to the :term:`primary` of each shard, and remove any
55-
reference to the removed namespace from the ``cache.databases``,
56-
``cache.collections``, and ``cache.chunks.DATABASE.COLLECTION``
57-
collections:
58-
59-
.. code-block:: javascript
60-
61-
db.getSiblingDB("config").cache.databases.remove({_id:"DATABASE"}, {writeConcern: {w: 'majority' }});
62-
db.getSiblingDB("config").cache.collections.remove({_id:/^DATABASE.*/}, {writeConcern: {w: 'majority' }});
63-
db.getSiblingDB("config").getCollectionNames().forEach(function(y) {
64-
if(y.indexOf("cache.chunks.DATABASE.") == 0)
65-
db.getSiblingDB("config").getCollection(y).drop()
66-
})
67-
68-
Where ``DATABASE`` represents the namespace of the database you
69-
just dropped.
70-
71-
#. Use the :dbcommand:`flushRouterConfig` command on **all**
72-
:binary:`~bin.mongos` instances before reading or writing to that
73-
database.
74-
7532
These steps ensure that all cluster nodes refresh their metadata cache,
7633
which includes the location of the :ref:`primary shard<primary-shard>`
7734
for the new database. Otherwise, you may miss data on reads, and may not

0 commit comments

Comments
 (0)