Skip to content

repairDatabase can be run on the secondaries in 2.6 #1884

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
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
2 changes: 1 addition & 1 deletion source/includes/note-repair.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
When using :term:`journaling <journal>`, there is almost never
any need to run :dbcommand:`repairDatabase`. In the event of an
unclean shutdown, the server will be able restore the data files
unclean shutdown, the server will be able to restore the data files
to a pristine state automatically.
8 changes: 4 additions & 4 deletions source/includes/warning-repair.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
operations remove and do not save any corrupt data during the
repair process.

If you are trying to repair a :term:`replica set` member, and you
have access to an intact copy of your data (e.g. a recent backup or
an intact member of the :term:`replica set`), you should restore
from that intact copy, and **not** use :dbcommand:`repairDatabase`.
If you are trying to repair a :term:`replica set` member, and you have
access to an intact copy of your data (e.g. a recent backup or an
intact member of the :term:`replica set`), you should restore from that
intact copy, and **not** use :dbcommand:`repairDatabase`.
9 changes: 5 additions & 4 deletions source/reference/command/repairDatabase.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ repairDatabase

.. default-domain:: mongodb

.. contents::
:backlinks: none
:local:

Definition
----------

Expand Down Expand Up @@ -65,6 +61,11 @@ Definition
Behavior
--------

.. versionchanged:: 2.6

The :dbcommand:`repairDatabase` command is now available for secondary
as well as primary members of replica sets.

The :dbcommand:`repairDatabase` command compacts all collections in the
database. It is identical to running the :dbcommand:`compact` command on
each collection individually.
Expand Down
18 changes: 14 additions & 4 deletions source/reference/method/db.repairDatabase.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,22 @@ db.repairDatabase()

.. method:: db.repairDatabase()

.. include:: /includes/warning-repair.rst

.. include:: /includes/note-repair.rst

:method:`db.repairDatabase()` provides a wrapper around the database
command :dbcommand:`repairDatabase`, and has the same effect as
the run-time option :option:`mongod --repair` option, limited to
*only* the current database. See :dbcommand:`repairDatabase` for
full documentation.

Behavior
--------

.. include:: /includes/warning-repair.rst

.. include:: /includes/note-repair.rst

.. versionchanged:: 2.6

The :dbcommand:`repairDatabase` command works on primary and secondary
members of a replica set. Because writes to secondaries are not
allowed, the command only compacts secondaries to reclaim disk space.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these sentences be more or less identical to the sentence in the command except for swapping out the command reference for the method?