|
With 2.4.9's mongod and shell, it looks like I can make a document at most 17 bytes too big:
var maxBsonObjectSize = db.isMaster().maxBsonObjectSize;
|
var bigness = maxBsonObjectSize - 24;
|
var big_string = '';
|
|
while (big_string.length < bigness) big_string += 'a';
|
|
db.collection.drop();
|
var result = db.collection.update(
|
{x: 1},
|
{$set: {s: big_string}},
|
true);
|
|
printjson(db.getLastErrorObj());
|
var overbigness = Object.bsonsize(db.collection.findOne()) - maxBsonObjectSize;
|
print('made document ' + overbigness + ' bytes too big.');
|
Result:
{
|
"updatedExisting" : false,
|
"upserted" : ObjectId("53177d64758be60887fe822c"),
|
"n" : 1,
|
"connectionId" : 23,
|
"err" : null,
|
"ok" : 1
|
}
|
made document 17 bytes too big.
|
If I try to make a document 18 bytes too big, I get:
{
|
"err" : "update object too large",
|
"code" : 10055,
|
"n" : 0,
|
"connectionId" : 22,
|
"ok" : 1
|
}
|
This behavior in 2.4 perhaps merits its own ticket.
|