[JAVA-1171] Allow command documents to exceed the max document size Created: 17/Apr/14  Updated: 01/Aug/14  Resolved: 28/Apr/14

Status: Closed
Project: Java Driver
Component/s: Command Operations
Affects Version/s: None
Fix Version/s: 2.12.1

Type: Improvement Priority: Major - P3
Reporter: John Morales Assignee: Jeffrey Yemin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Related
is related to JAVA-1189 Allow command documents to exceed max... Closed

 Description   

Several commands, e.g. findAndModify, may be used to insert or replace a document that is up to the exact 16MB max BSON object size. MongoDB servers allow this, and therefore should be allowed by the driver for.

Currently however the extra surrounding "envelope" bytes of the message cause the total payload size to exceed 16MB, tripping the OutMessage validation.

Example stack trace:

com.mongodb.MongoInternalException: DBObject of size 16777340 is over Max BSON size 16777216
    at com.mongodb.OutMessage.putObject(OutMessage.java:291)
    at com.mongodb.OutMessage.writeQuery(OutMessage.java:211)
    at com.mongodb.OutMessage.query(OutMessage.java:84)
    at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:285)
    at com.mongodb.DB.command(DB.java:262)
    at com.mongodb.DB.command(DB.java:229)
    at com.mongodb.DB.command(DB.java:214)
    ...



 Comments   
Comment by Githook User [ 01/Aug/14 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-1171: Allowing query documents to exceed the maximum document size by 16K, so that, for example, the findAndModify command can be used to upsert a 16M document. Without this headroom, the additional space taken by the surrounding command document would push it over 16M, and the driver would through an exception. 16K was chosen as the value because it matches the constant used in the server code base.
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/a3fd1f3714e0eecab78a01793df5263be0e3187e

Comment by Jeffrey Yemin [ 29/Apr/14 ]

Closing for 2.12.1 release.

Comment by Githook User [ 25/Apr/14 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-1171: Allowing query documents to exceed the maximum document size by 16K, so that, for example, the findAndModify command can be used to upsert a 16M document. Without this headroom, the additional space taken by the surrounding command document would push it over 16M, and the driver would through an exception. 16K was chosen as the value because it matches the constant used in the server code base.
Branch: 2.12.x
https://github.com/mongodb/mongo-java-driver/commit/a3fd1f3714e0eecab78a01793df5263be0e3187e

Comment by Jeffrey Yemin [ 17/Apr/14 ]

We solved a similar problem for the new write commands (e.g., insert or update a 16MB document), so shouldn't be too difficult.

Generated at Thu Feb 08 08:53:57 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.