I have a MongoDB collection backup containing many small documents. The back up was produced by mongodump
, but when I try to import it using mongorestore
I get an error:
AssertionException handling request, closing client connection: 10334 BSONObj size: 18039019 (0x11340EB) is invalid. Size must be between 0 and 16793600(16MB)
I'm running MongoDB version 3.0.3 (from trunk).
Using --batchSize=100
fixes this issue for me every time.
e.g. mongorestore -d my-database --batchSize=100 ./database-dump-directory
Basically mongoDB accept the size of the document should be less than 16MB.If you intent to use the document which is more than 16MB ,you can use gridfs. Each document takes memory power of 2 size allocation. Your application should ensure the size of bson document it is generating..Or else you can use the different data model rather than embedding all the data in one doc.
mongorestore
send insert commands by batch in a {"applyOps", entries}
document. This document is (AFAIK) limited to 16MB just like any other document.
According to the sources there are "pathological cases where the array overhead of many small operations can overflow the maximum command size". The variable oplogMaxCommandSize
is used to help mongorestore
to not fail on such cases. It was raised to 16.5M at some point during the 3.0... development. That was too optimistic. It was lowered back to 8M later (JIRA TOOLS-754).
If you need to, you may adjust that value yourself according to your needs. And then recompile the tools.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With