5
votes

I use mongo 2.6.4 / Windows Server 2012 R2.

Mongodump generated two dump files: mongodump -d mydb

  • transaction.bson
  • transaction.metadata.json

I tried to restore this information by mongorestore (2.6.4):

mongorestore --host 127.0.0.1 --port 27018 --collection transaction --db mydb

But tool return error (progress ~23%):

2015-08-17T19:45:51.844+0400 Failed: restore error: mydb.transaction: error restoring from F:\restore\transaction.bson: insertion error: Client Error: bad object in message: invalid bson type in object with _id: ObjectId('528dc7c03599b01214d17469')

So I decided to extend it by flags:

mongorestore --host 127.0.0.1 --port 27018 --collection transaction --db mydb --drop --noIndexRestore --noOptionsRestore --noobjcheck --filter "{'_id' : { $ne: '528dc7c03599b01214d17469' }}" F:/restore/transaction.bson

And got the same error again.

So I tried to use mongorestore from 3.0 version:

mongorestore /host 127.0.0.1 /port 27018 /collection transaction /db mydb /drop /noIndexRestore /noOptionsRestore /keepIndexVersion F:/restore/transaction.bson

And got the same error again.

I was hoping it helps because I didn't use /stopOnError flag. But it's not. All the time it fails at ~23%.

Here is part of MongoDB log:

2015-08-17T19:14:32.447+0400 [conn8] Assertion: 10307:Client Error: bad object in message: invalid bson type in object with _id: ObjectId('528dc7c03599b01214d17469') 2015-08-17T19:14:32.532+0400 [conn6] insert mydb.transaction ninserted:10000 keyUpdates:0 numYields:0 locks(micros) w:181893 181ms 2015-08-17T19:14:32.743+0400 [conn9] insert mydb.transaction ninserted:10000 keyUpdates:0 numYields:0 locks(micros) w:211264 211ms 2015-08-17T19:14:32.921+0400 [conn7] insert mydb.transaction ninserted:10000 keyUpdates:0 numYields:0 locks(micros) w:176525 177ms 2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\util\stacktrace.cpp(169) mongo::printStackTrace+0x43 2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\util\log.cpp(127) mongo::logContext+0x9c 2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\util\assert_util.cpp(183) mongo::msgasserted+0xfb 2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\util\assert_util.cpp(174) mongo::msgasserted+0x13 2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\db\dbmessage.cpp(116) mongo::DbMessage::nextJsObj+0x11f 2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\db\instance.cpp(898) mongo::receivedInsert+0x18f 2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\db\instance.cpp(484) mongo::assembleResponse+0x7c9 2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\db\db.cpp(202) mongo::MyMessageHandler::process+0x111 2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\util\net\message_server_port.cpp(210) mongo::PortMessageServer::handleIncomingMsg+0x671 2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\third_party\boost\libs\thread\src\win32\thread.cpp(185) boost::'anonymous namespace'::thread_start_function+0x21 2015-08-17T19:14:36.250+0400 [conn8] mongod.exe f:\dd\vctools\crt_bld\self_64_amd64\crt\src\threadex.c(314) _callthreadstartex+0x17 2015-08-17T19:14:36.250+0400 [conn8] mongod.exe f:\dd\vctools\crt_bld\self_64_amd64\crt\src\threadex.c(292) _threadstartex+0x7f 2015-08-17T19:14:36.250+0400 [conn8] KERNEL32.DLL BaseThreadInitThunk+0xd 2015-08-17T19:14:36.250+0400 [conn8] 2015-08-17T19:14:36.255+0400 [conn8] insert mydb.transaction keyUpdates:0 exception: Client Error: bad object in message: invalid bson type in object with _id: ObjectId('528dc7c03599b01214d17469') code:10307 numYields:0 0ms

I want to read data from this file, but it's huge (18 Gb). It's okay if some records will be skipped.

Anybody knows how to solve this?

1

1 Answers

0
votes

mongodump is good to dump the whole db. If you just want to work with one collection, try to export the transaction collection with mongoexport like mongoexport --collection transaction --db mydb --out transaction.json and import it with mongoimport --collection transaction --db mydb --file transaction.json. If you are restoring a full dump and it fails with a certain collection then you can do the restore without the offending collection by using the following flag --excludeCollection transaction