Skip to content

DOCS-1765: Mention compact and replSetMaintenance for RECOVERING #1155

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

Closed
wants to merge 1 commit into from
Closed
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
13 changes: 13 additions & 0 deletions source/includes/fact-command-puts-secondary-into-recovering.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.. |cmd-name| specified in the including file

.. important:: On secondaries, the |cmd-name| command forces
the secondary to enter :replstate:`RECOVERING` state. This prevents
clients from reading during compaction. Once the operation
finishes, the secondary returns to :replstate:`SECONDARY` state.

See :doc:`/reference/replica-states/` for more information about
replica set member states. Refer to the "`partial script for
automating step down and compaction`_" for an example of this
procedure.

.. _`partial script for automating step down and compaction`: https://github.com/mongodb/mongo-snippets/blob/master/js/compact-example.js
15 changes: 2 additions & 13 deletions source/reference/command/compact.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,8 @@ Replica Sets
- Ideally run :dbcommand:`compact` on a secondary. See option
``force:true`` above for information regarding compacting the primary.

.. warning::

If you run :dbcommand:`compact` on a secondary, the secondary will
enter a ``RECOVERING`` state to prevent clients from sending read
operations during compaction. Once the operation finishes the
secondary will automatically return to ``SECONDARY`` state. See
:data:`~replSetGetStatus.members.state` for more information about
replica set member states. Refer to the "`partial script for
automating step down and compaction`_" for an example of this
procedure.
.. |cmd-name| replace:: :dbcommand:`compact`
.. include:: /includes/fact-command-puts-secondary-into-recovering.rst

Sharded Clusters
~~~~~~~~~~~~~~~~
Expand All @@ -198,6 +190,3 @@ It is not possible to compact :term:`capped collections <capped
collection>` because they don't have padding, and documents cannot grow
in these collections. However, the documents of a :term:`capped
collection` are not subject to fragmentation.

.. _`partial script for automating step down and compaction`:
https://github.com/mongodb/mongo-snippets/blob/master/js/compact-example.js
3 changes: 3 additions & 0 deletions source/reference/command/replSetMaintenance.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@ replSetMaintenance

- The member continues to sync its :term:`oplog` from the Primary.

.. |cmd-name| replace:: :dbcommand:`compact`
.. include:: /includes/fact-command-puts-secondary-into-recovering.rst

.. admin-only
15 changes: 10 additions & 5 deletions source/reference/replica-states.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,18 @@ Initialization States
rest of the set. While resyncing, the member enters the
:replstate:`RECOVERING` state.

Likewise, whenever the set replaces a :term:`primary` in an
election, its data collection may contain documents that did not
have time to replicate to the :term:`secondary` members. In this
case the member rolls back those writes. Following :doc:`rollback
</core/replica-set-rollbacks>`, the member will have
Whenever the replica set replaces a :term:`primary` in an
election, the old primary's data collection may contain documents
that did not have time to replicate to the :term:`secondary`
members. In this case the member rolls back those writes. During
:doc:`rollback </core/replica-set-rollbacks>`, the member will have
:replstate:`RECOVERING` state.

On secondaries, the :dbcommand:`compact` and
:dbcommand:`replSetMaintenance` commands force the secondary to enter
:replstate:`RECOVERING` state. This prevents clients from reading
during those operations.

Error States
~~~~~~~~~~~~

Expand Down