[SERVER-4727] MaxBytesToReturnToClientAtOnce seems inconsistent with BSONObjMaxUserSize Created: 19/Jan/12  Updated: 11/Jan/16  Resolved: 11/Jan/16

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

Type: Bug Priority: Major - P3
Reporter: Aaron Staple Assignee: David Storch
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-21797 Simplify find batching logic Closed
Operating System: ALL
Participants:

 Description   

    /* Note the limit here is rather arbitrary and is simply a standard. generally the code works
       with any object that fits in ram.
 
       Also note that the server has some basic checks to enforce this limit but those checks are not exhaustive
       for example need to check for size too big after
         update $push (append) operation
         various db.eval() type operations
    */
    const int BSONObjMaxUserSize = 16 * 1024 * 1024;

    /* We cut off further objects once we cross this threshold; thus, you might get
       a little bit more than this, it is a threshold rather than a limit.
    */
    const int MaxBytesToReturnToClientAtOnce = 4 * 1024 * 1024;

If my objects are ~5mb, and I do a find().limit(-2) I will only get one document back.

test

c = db.c;
c.drop();
 
for( i = 0; i < 2; ++i ) {
    c.save( {} );
}
 
print( c.find().limit( -2 ).itcount() );
 
c.drop();
 
big = new Array( 5 * 1024 * 1024 ).toString();
 
for( i = 0; i < 2; ++i ) {
    c.save( {big:big} );
}
 
print( c.find().limit( -2 ).itcount() );


Generated at Thu Feb 08 03:06:48 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.