Mongodb: Restore database with broken document

967 views Asked by At

I have problem to restore our database with broken document. mongorestore stops to restore when broken document came out. Here is error.

INVALID OBJECT - going to try and print out
size: 2760
error: bson length doesn't match what we found in object with _id: 2
2014-11-21T12:29:48.717+0900 Assertion: 10330:Element extends past end of object
2014-11-21T12:29:48.740+0900 mongorestore.exe    mongo::parseNumberFromStringWithBase<unsigned char>+0x730af3
2014-11-21T12:29:48.741+0900 mongorestore.exe    mongo::parseNumberFromStringWithBase<unsigned char>+0x6db6bc
2014-11-21T12:29:48.741+0900 mongorestore.exe    mongo::parseNumberFromStringWithBase<unsigned char>+0x6c86db
2014-11-21T12:29:48.745+0900 mongorestore.exe    mongo::parseNumberFromStringWithBase<unsigned char>+0x4280
2014-11-21T12:29:48.749+0900 mongorestore.exe    mongo::parseNumberFromStringWithBase<unsigned char>+0x6c1382
2014-11-21T12:29:48.755+0900 mongorestore.exe    mongo::parseNumberFromStringWithBase<unsigned char>+0xafd52b
2014-11-21T12:29:48.758+0900 mongorestore.exe    mongo::parseNumberFromStringWithBase<unsigned char>+0xaff663
2014-11-21T12:29:48.762+0900 mongorestore.exe    mongo::parseNumberFromStringWithBase<unsigned char>+0xafe97b
2014-11-21T12:29:48.765+0900 mongorestore.exe    mongo::parseNumberFromStringWithBase<unsigned char>+0xafe97b
2014-11-21T12:29:48.772+0900 mongorestore.exe    mongo::parseNumberFromStringWithBase<unsigned char>+0xb01584
2014-11-21T12:29:48.777+0900 mongorestore.exe    mongo::parseNumberFromStringWithBase<unsigned char>+0x6c1b03
2014-11-21T12:29:48.780+0900 mongorestore.exe    mongo::parseNumberFromStringWithBase<unsigned char>+0x6c1beb
2014-11-21T12:29:48.784+0900 mongorestore.exe    mongo::parseNumberFromStringWithBase<unsigned char>+0xb364e3
2014-11-21T12:29:48.792+0900 kernel32.dll        BaseThreadInitThunk+0xd
2014-11-21T12:29:48.795+0900
object up to error: { HERE IS BROKEN DOCUMENT 
assertion: 10330 Element extends past end of object

Actually same error happened before back up. It's still unknown why the document has been broken (Just guess it might be unexpected shutdown). Replica set is not used that server and journaling was enabled. The .find() command that retrieves the broken document always failed. Broken document is identified by .valid() command too. But mongodb couldn't recover it with db.repairDatabase() and mongod --repair. My temporary measure was backed up data using mongodump, then removed broken document using .remove() command.

Now the problem is how to restore complete database from backup and how to repair it properly. Is there any way to restore database with (or without) the broken document?

MongoDB version: 2.6.1

1

There are 1 answers

0
alernerdev On BEST ANSWER

It sounds like you have backed up a database that was corrupt to start with. Try running mongorestore with the --noobjcheck option.
Hope this helps.