Object.bsonsize({ ...... }) will calculate the BSON size of the document.
Also 10000000/1024/1024 is only ~ 9mb so I'm not sure your test would have caught it.
Question
I am running a map/reduce job and it fails because the reduce step exceeds the 16 mb limit for bson documents. And I run out of ideas how to debug it.
exception: BSONObj size: 16808001 (0x41780001) is invalid.
Size must be between 0 and 16793600(16MB)
First element: 0: { 531.343: { 2: [ { strength: 121.0, acc: 23.0 } ] } }
My problem is that I don't got access to the document but only the first element of the input. Is there a way to get the complete thing?
My idea was to check the size of the output within the reduce javascript and print the data into the mongo log. But
if(JSON.stringify(ret).length > 10000000) {
print('Document of size: ' + JSON.stringify(ret).length);
print(JSON.stringify(ret));
print();
}
return ret;
Any other ideas?
Solution
Object.bsonsize({ ...... }) will calculate the BSON size of the document.
Also 10000000/1024/1024 is only ~ 9mb so I'm not sure your test would have caught it.