[SERVER-4968] Aggregation fails with ambiguous assertion when applied to a collection with forbidden BSON types Created: 14/Feb/12  Updated: 15/Aug/12  Resolved: 01/Mar/12

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: 2.1.0
Fix Version/s: 2.1.1

Type: Improvement Priority: Major - P3
Reporter: Daniel Pasette (Inactive) Assignee: Chris Westin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-4644 aggregation: optimize memory utilitz... Closed
Backwards Compatibility: Fully Compatible
Participants:

 Description   

If you run aggregate on a collection containing one of the following fields

  • MinKey
  • MaxKey
  • EOO
  • Undefined
  • DBRef
  • Code

Example:

> db.foo.insert( { x : MinKey } )
> db.foo.find()
{ "_id" : ObjectId("4f3ad5dc7302cfae80686b02"), "x" : { $minKey : 1 } }
> db.foo.aggregate( { $project: { x : 1 } } )
{
	"errmsg" : "exception: assertion src/mongo/db/pipeline/value.cpp:183",
	"code" : 0,
	"ok" : 0
}

Server output:

Tue Feb 14 16:46:11 [conn1]  local.foo Assertion failure false src/mongo/db/pipeline/value.cpp 183
0x100154641 0x10062a92d 0x100259696 0x100259b22 0x10019e356 0x10019e972 0x1006440d8 0x1006442e5 0x10024e55d 0x10014ba9c 0x1003d0a99 0x10030a804 0x10030d0f4 0x10030fa27 0x1001fb544 0x1001fd83f 0x1001d619e 0x1001dfbc6 0x1000206a4 0x100275c70 
 0   mongod                              0x0000000100154641 _ZN5mongo12sayDbContextEPKc + 161
 1   mongod                              0x000000010062a92d _ZN5mongo8assertedEPKcS1_j + 269
 2   mongod                              0x0000000100259696 _ZN5mongo5ValueC2EPNS_11BSONElementE + 1862
 3   mongod                              0x0000000100259b22 _ZN5mongo5Value21createFromBsonElementEPNS_11BSONElementE + 50
 4   mongod                              0x000000010019e356 _ZN5mongo8DocumentC2EPNS_7BSONObjE + 278
 5   mongod                              0x000000010019e972 _ZN5mongo8Document17createFromBsonObjEPNS_7BSONObjE + 50
 6   mongod                              0x00000001006440d8 _ZN5mongo20DocumentSourceCursor8findNextEv + 488
 7   mongod                              0x00000001006442e5 _ZN5mongo20DocumentSourceCursor3eofEv + 53
 8   mongod                              0x000000010024e55d _ZN5mongo21DocumentSourceProject3eofEv + 29
 9   mongod                              0x000000010014ba9c _ZN5mongo8Pipeline3runERNS_14BSONObjBuilderERSsRKN5boost13intrusive_ptrINS_14DocumentSourceEEE + 604
 10  mongod                              0x00000001003d0a99 _ZN5mongo15PipelineCommand3runERKSsRNS_7BSONObjEiRSsRNS_14BSONObjBuilderEb + 153
 11  mongod                              0x000000010030a804 _ZN5mongo12_execCommandEPNS_7CommandERKSsRNS_7BSONObjEiRNS_14BSONObjBuilderEb + 148
 12  mongod                              0x000000010030d0f4 _ZN5mongo11execCommandEPNS_7CommandERNS_6ClientEiPKcRNS_7BSONObjERNS_14BSONObjBuilderEb + 2148
 13  mongod                              0x000000010030fa27 _ZN5mongo12_runCommandsEPKcRNS_7BSONObjERNS_11_BufBuilderINS_16TrivialAllocatorEEERNS_14BSONObjBuilderEbi + 2359
 14  mongod                              0x00000001001fb544 _ZN5mongo11runCommandsEPKcRNS_7BSONObjERNS_5CurOpERNS_11_BufBuilderINS_16TrivialAllocatorEEERNS_14BSONObjBuilderEbi + 52
 15  mongod                              0x00000001001fd83f _ZN5mongo8runQueryERNS_7MessageERNS_12QueryMessageERNS_5CurOpES1_ + 3343
 16  mongod                              0x00000001001d619e _ZN5mongo13receivedQueryERNS_6ClientERNS_10DbResponseERNS_7MessageE + 654
 17  mongod                              0x00000001001dfbc6 _ZN5mongo16assembleResponseERNS_7MessageERNS_10DbResponseERKNS_11HostAndPortE + 870
 18  mongod                              0x00000001000206a4 _ZN5mongo16MyMessageHandler7processERNS_7MessageEPNS_21AbstractMessagingPortEPNS_9LastErrorE + 148
 19  mongod                              0x0000000100275c70 _ZN5mongo3pms9threadRunEPNS_13MessagingPortE + 768

This error will happen if an illegal type is in any of the documents passed into aggregation. Should be documented and improve the error message.



 Comments   
Comment by auto [ 12/Jul/12 ]

Author:

{u'date': u'2012-06-29T16:49:56-07:00', u'email': u'mathias@10gen.com', u'name': u'Mathias Stearn'}

Message: If there is an early simple $project, apply it before converting to Documents SERVER-4644

This is a partial fix for SERVER-4644 in that it only works with an
explicit $project and only if that project is supported by the existing
Projection class used to implement the second argument to find().

This also provides a workaround for objects with types that aren't
supported by the Value class (SERVER-4608, SERVER-5718, and SERVER-4968.
Previous behavior was to assert with no possible workaround.

This commit will need some doc updates, in particular in the "Optimizing
Performance" section.
Branch: master
https://github.com/mongodb/mongo/commit/c62b02c1dbc95d0ed1a57231298aa2d81dd84c39

Comment by auto [ 01/Mar/12 ]

Author:

{u'login': u'tychoish', u'name': u'Sam Kleinman', u'email': u'samk@10gen.com'}

Message: SERVER-4968: adding warning about forbiden BSON types in aggregation pipleine
Branch: master
https://github.com/mongodb/docs/commit/76c282a62e263de7a97922025244e36d7e7d43c4

Comment by auto [ 01/Mar/12 ]

Author:

{u'login': u'cwestin', u'name': u'U-tellus\\cwestin', u'email': u'cwestin@10gen.com'}

Message: SERVER-4968
Branch: master
https://github.com/mongodb/mongo/commit/4bc0143d3f44d51a76a03e90b66cfec466e8e9ee

Comment by Chris Westin [ 25/Feb/12 ]

Ideally, we wouldn't bring these values into the pipeline at all if they aren't referenced, per SERVER-4644. Some of them may make sense, but if we decide to support them, they will require special handling from relational operators such as $lt, $lte, etc, etc,...

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