Mongodb – Mongo repair database “ERROR: error: exception cloning object in local.system.replset ”

mongo-repairmongodb

I'm trying to repair a mongo database and am running into the following error early on:

Wed Jul 24 16:55:21 [initandlisten] ERROR: error: exception cloning object in local.system.replset 
E11000 duplicate key error index: local.system.replset.$_id_  dup key: { : "replicaset-name" } 
obj:{ _id: "replicaset-name", version: 92, members: [ { _id: 16, host: "host1:27032" },
 { _id: 17, host: "host2:27032" },
 { _id: 18, host: "host3:27032", priority: 0.0, hidden: true },
 { _id: 19, host: "host4:27032", priority: 6.0 },
 { _id: 20, host: "host5:27032", priority: 7.0 },
 { _id: 22, host: "host6:27032", priority: 4.0 },
 { _id: 23, host: "host7:27032", priority: 3.0 },
 { _id: 24, host: "host8:27032", votes: 0, priority: 0.0 } ] }

(replica set and host names have been sanitized for public posting)

To attempt the repair I shut down the mongod and started it up with

/usr/bin/mongod-2.2 -f /var/local/mongo/mongod.conf --nojournal --repair --repairpath /mnt/mongo_repair/

My mongod.conf consists of just two lines:

dbpath = /var/local/mongo/data/replicaset-name
port = 17000

The .conf normally did have a replSet declaration, but this was removed for the repair as I'm trying to run the repair on a secondary. (Per the docs repairs can only be done on primaries or standalones; so need to make it look like a standalone temporarily).

Any idea what the problem could be?

Best Answer

ReplSet configuration exists on many other members of that replica set. You can safely drop the local db collections (you can even drop the whole DB but then you will just end up syncing from another replica and there is no point to repairing this entire DB). So drop the troublesome collection - it will be recreated when the host rejoins its replica set. The only local collection you need to keep will be the oplog.rs collection - this would allow this member to know where to start catching up for operations it misses while you are doing repairs.