Search code examples
mongodbcorruption

How to handle corrupt namespace in journaled MongoDB instance?


I've found that my MongoDB instance has a corruption problem. The validate command returns:

{ 

    ...stuff...

    "advice" : "ns corrupt, requires repair",
    "ok" : 1
}

I think this may be a corrupt index, but I can't figure out which index. The collection is very large, so reindexing is not ideal.

I would try repairDatabase but it's not recommended for journaled instances; mine is definitely journaled (checked with serverStatus).

Note: When using journaling, there is almost never any need to run repairDatabase. In the event of an unclean shutdown, the server will be able restore the data files to a pristine state automatically.

Short of rebuilding all indexes (which may or may not fix the corruption), what can I try?


Solution

  • It did seem to be a corrupt index. Running reIndex() seems to have fixed the problem.