--help section for mongodump --repair looks like this:
--repair try to recover a crashed database
And it may sound like the mongodump will try to "fix" the database. But in fact it is a read only operation that tries to read the contents of a database by iterating over the extents manually. For mmap v1, this goes through 2 passes - iterating to the next record and iterating to the prev record. In other words, if the database is in a valid state, each document will appear twice.
We also need to fix our documentation since it is not correct:
Runs a repair option in addition to dumping the database. The repair option attempts to repair a database that may be in an invalid state as a result of an improper shutdown or mongod crash.
The --repair option uses aggressive data-recovery algorithms that may produce a large amount of duplication.
- is documented by
DOCS-4554 Revisit description of mongodump --repair option