Skip to content

Commit 2d2cfa0

Browse files
ajhuh-mdbandf-mongodb
authored andcommitted
DOCS-1463 update renameCollection documents for sharded collections, resource locking, and exceptions
1 parent 1d5685b commit 2d2cfa0

File tree

3 files changed

+20
-25
lines changed

3 files changed

+20
-25
lines changed

source/includes/extracts-mongos-operations.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ content: |
2121
:dbcommand:`renameCollection` command and its helper
2222
:method:`db.collection.renameCollection()` to
2323
:writeconcern:`"majority"`.
24-
25-
.. note::
26-
27-
You cannot rename a sharded collection. You can however rename an
28-
unsharded collection in a sharded cluster.
29-
3024
---
3125
ref: mongos-operations-wc-create
3226
content: |

source/reference/command/renameCollection.txt

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,16 @@ Behavior
9797
Sharded Collections
9898
~~~~~~~~~~~~~~~~~~~
9999

100-
:dbcommand:`renameCollection` is **not** compatible with sharded collections.
100+
Starting in MongoDB 5.0, you can use the :dbcommand:`renameCollection`
101+
command to change the name of a sharded collection. The target
102+
database must be the same as the source database.
103+
104+
Unsharded Collections
105+
~~~~~~~~~~~~~~~~~~~~~
106+
107+
You can use :dbcommand:`renameCollection` to rename an unsharded
108+
collection in a sharded cluster as long as the source and target
109+
databases are on the same primary shard.
101110

102111
Existing Target Collection
103112
~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -122,14 +131,14 @@ If the target database differs from the source database,
122131
collection to the target collection. Depending on the size of the
123132
collection, this may take longer to complete.
124133

125-
Resource Locking
126-
~~~~~~~~~~~~~~~~
134+
Resource Locking in Replica Sets
135+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
127136

128137
.. versionchanged:: 4.2
129138

130139
If renaming a collection within the same database,
131-
:dbcommand:`renameCollection` obtains an exclusive lock on the
132-
source and target collections for the duration of the operation.
140+
:dbcommand:`renameCollection` obtains an exclusive lock on
141+
the source and target collections for the duration of the operation.
133142
All subsequent operations on the collections must wait until
134143
:dbcommand:`renameCollection` completes.
135144

@@ -208,17 +217,3 @@ equivalent to the previous example:
208217

209218
use test
210219
db.orders.renameCollection( "orders2014" )
211-
212-
Exceptions
213-
----------
214-
215-
exception 10026
216-
Raised if the ``source`` namespace does not exist.
217-
218-
exception 10027
219-
Raised if the ``target`` namespace exists and ``dropTarget`` is
220-
either ``false`` or unspecified.
221-
222-
exception 15967
223-
Raised if the ``target`` namespace is an invalid collection
224-
name.

source/release-notes/5.0.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,12 @@ for the ``"matchPrimaryNode"`` option. When set for a
297297
:binary:`~bin.mongod`, the instance follows the behavior specified for
298298
the ``"disabled"`` option.
299299

300+
``renameCollection`` Compatible with Sharded Collections
301+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
302+
303+
Starting in MongoDB 5.0, you can use the :dbcommand:`renameCollection`
304+
command to change the name of a sharded collection.
305+
300306
.. _5.0-rel-notes-shell:
301307

302308
Shell Changes

0 commit comments

Comments
 (0)