[SERVER-654] $push allows BSON object to exceed 4MB Created: 22/Feb/10  Updated: 12/Jul/16  Resolved: 23/Feb/10

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 1.3.2
Fix Version/s: 1.3.3

Type: Bug Priority: Minor - P4
Reporter: Yun Huang Yong Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

Growing an object size through the use of $push doesn't trigger the 4MB object limit error.

JS shell session that creates an object of 5MB, by $push ing 1MB strings onto an array:

> s = "x"
> for(i = 0; i < 20; i++) s += s
> s.length // 1MB string
1048576
> db.test.remove()
> db.test.insert(

{a:[]}

)
ObjectId("4b83590a8f668d84b215eaa5")
> for(i = 0; i < 5; i++) db.test.update({}, {$push: {a:s}}) // push 5 times = ~5 MB object size
> db.test.findOne().a.length
5
> db.getLastError()
null



 Comments   
Comment by Eliot Horowitz (Inactive) [ 23/Feb/10 ]

not quite - there are a few places its a bit different for now
at some point maybe

Comment by Yun Huang Yong [ 23/Feb/10 ]

Would it be tidier to MaxBSONObjectSize from db.h instead of the magic number?

Comment by auto [ 23/Feb/10 ]

Author:

{'login': 'erh', 'name': 'Eliot Horowitz', 'email': 'eliot@10gen.com'}

Message: check that objects modified with $ operators are <= 4mb SERVER-654
http://github.com/mongodb/mongo/commit/0f88bb48d2e1dc476487042db1c5b47d0bd9e69c

Generated at Thu Feb 08 02:54:47 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.