Skip to content

DOCS-10528 update lock info on renameCollections #3071

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions source/faq/concurrency.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ the lock for a very short time:
- :method:`db.serverStatus()`,
- :method:`db.auth()`, and
- :method:`db.addUser()`.
- :method:`db.collection.renameCollection()`

.. _faq-concurrency-lock-multiple-dbs:

Expand Down
31 changes: 16 additions & 15 deletions source/reference/command/renameCollection.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,33 +43,34 @@ Definition
Behavior
--------

:dbcommand:`renameCollection` is suitable for production
environments; *however*:
:dbcommand:`renameCollection` is **not** compatible with sharded collections.

- :dbcommand:`renameCollection` blocks all database activity for the
duration of the operation.
:dbcommand:`renameCollection` fails if ``target`` is the name of an existing
collection *and* you do not specify ``dropTarget: true``.

- :dbcommand:`renameCollection` is **not** compatible with sharded
collections.
.. versionchanged:: 3.6

- :dbcommand:`renameCollection` fails if ``target`` is the name of an
existing collection *and* you do not specify ``dropTarget: true``.
:dbcommand:`renameCollection` has different performance implications depending
on the target :term:`namespace`.

.. warning::

If the :dbcommand:`renameCollection` operation does not complete,
the ``target`` collection and indexes will not be usable and
will require manual intervention to clean up.
If the target database is the same as the source database,
:dbcommand:`renameCollection` simply changes the namespace. This is a quick
operation.

If the target database differs from the source database,
:dbcommand:`renameCollection` copies all documents from the source collection
to the target collection. Depending on the size of the collection, this
may take longer to complete. Other operations which require exclusive
access to the affected databases will be blocked until the rename completes.
See :ref:`faq-concurrency-operations-locks` for operations which require
exclusive access to all databases.

Example
-------

The following example renames a collection named ``orders`` in the
``test`` database to ``orders2014`` in the ``test`` database.

.. include:: /includes/warning-blocking-global.rst

.. code-block:: javascript

db.adminCommand( { renameCollection: "test.orders", to: "test.orders2014" } )
Expand Down