-
Type: Bug
-
Resolution: Fixed
-
Priority: Critical - P2
-
Affects Version/s: None
-
Component/s: manual
-
Labels:None
There are several issues with the repairDatabase documentation page in https://docs.mongodb.com/manual/reference/command/repairDatabase/
repairDatabase is an administrative command that needs to be run with due care, especially in a replica set configuration. However, the tone and content of the documentation page gives the impression that this is a "safe" command to run. As a result, the suggestion to run repairDatabase for the smallest of issues is often see in community advice.
In MMAPv1, repairDatabase rebuilds the data files based on the data that can be successfully read. Running this command in a replica set could potentially create inconsistencies in the set. Since all nodes in a replica set are assumed to contain identical data, this will lead to difficult to diagnose crashes and other surprising behaviour.
Confirmation will be needed as to what exactly repairDatabase does for WiredTiger.
A sample of incorrect and misleading statements in the page are:
- The repairDatabase command compacts all collections in the database. It is identical to running the compact command on each collection individually. This statement is very, very false and misleading. repairDatabase is not identical to bulk-compact.
- repairDatabase reduces the total size of the data files on disk Reducing data size is not the goal of repairDatabase
- However, if you trust that there is no corruption and you have enough free space, then repairDatabase is the appropriate and the only way to reclaim disk space. This statement is misleading. Reclaiming space should never be the goal of doing a repairDatabase.
The result of running repairDatabase may be irreversible. Hence, this command should come with:
- Encouragement to take a file copy backup of the dbpath before attempting any repair operations
- Information on what this command does for each storage engine
- Big warnings against running this in a replica set.
- Big warnings that you should not treat this command lightly, since the consequences of this command may be irreversible, lost data, etc.
- Big warnings that this command is a last resort.