[SERVER-11539] Aggregation command returning a document close to the maximum size fails. Created: 04/Nov/13  Updated: 11/Jul/16  Resolved: 13/Nov/13

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: 2.5.3
Fix Version/s: 2.5.4

Type: Bug Priority: Major - P3
Reporter: Robert Moore Assignee: Mathias Stearn
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

The session below shows how to create a document that is close to the maximum size and then retrieve it with an aggregation command (using a cursor) and with a findOne(). The aggregation fails.

MongoDB shell version: 2.5.3
connecting to: test
Server has startup warnings: 
2013-11-03T19:16:05.526-0500 [initandlisten] 
2013-11-03T19:16:05.526-0500 [initandlisten] ** NOTE: This is a development version (2.5.3) of MongoDB.
2013-11-03T19:16:05.526-0500 [initandlisten] **       Not recommended for production.
2013-11-03T19:16:05.526-0500 [initandlisten] 
// As big a document as we can make.
> var bytes=(16 * 1024 * 1024) - (4 + 6 + 5);
// ... using one large hex string.
> var hex=""
> for ( var i = 0; i < bytes; ++i ) { hex=hex+"00"; } ; db.test.insert( { "_id" : HexData( 0, hex ) } )
> db.test.find({}, { _id : 0 } )
{  }
> db.test.aggregate( { $match : {} } )
assert: command failed: {
	"errmsg" : "exception: Tried to create string longer than 16MB",
	"code" : 16493,
	"ok" : 0
} : aggregate with cursor failed
Error: Printing Stack Trace
    at printStackTrace (src/mongo/shell/utils.js:38:15)
    at doassert (src/mongo/shell/assert.js:6:5)
    at Function.assert.commandWorked (src/mongo/shell/assert.js:238:5)
    at DBCollection.aggregate (src/mongo/shell/collection.js:907:12)
    at (shell):1:9
2013-11-03T19:23:27.549-0500 command failed: {
	"errmsg" : "exception: Tried to create string longer than 16MB",
	"code" : 16493,
	"ok" : 0
} : aggregate with cursor failed at src/mongo/shell/assert.js:7
 
// Verify we can read the document without printing it out...
> Object.bsonsize( db.test.findOne({}) )
16777216

Participants:

 Description   

If the aggregation framework returns a cursor where the first document is close to the maximum size that it will fail with an error similar to:

assert: command failed: {
	"errmsg" : "exception: Tried to create string longer than 16MB",
	"code" : 16493,
	"ok" : 0
} : aggregate with cursor failed

See also this discussion on the Google Groups Developer List: https://groups.google.com/d/topic/mongodb-dev/Hi2DiX1F_FA/discussion



 Comments   
Comment by auto [ 13/Nov/13 ]

Author:

{u'username': u'RedBeard0531', u'name': u'Mathias Stearn', u'email': u'mathias@10gen.com'}

Message: SERVER-11539 Don't count sizeof metadata when deciding if a string is too big in agg
Branch: master
https://github.com/mongodb/mongo/commit/dd6c8449c0d3be8a66fa8446caed5b9071765dc2

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