[SERVER-6179] Sharded aggregation can't handle multiple $group commands Created: 22/Jun/12  Updated: 11/Jul/16  Resolved: 23/Jul/12

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: 2.2.0-rc1

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

Operating System: ALL
Participants:

 Description   

The current implementation assumes that when running in mongos it should be merging results from the shards. While this applies to the first $group, it doesn't apply to any others.

mongos> for (var i=0; i<100;i++) db.foo.insert({_id:i, i:i%10})
mongos> db.foo.aggregate({$group:{_id:'$_id', i:{$first:'$i'}}},{$group:{_id:'$_id', i:{$avg:'$i'}}})
{
	"errmsg" : "exception: assertion src/mongo/db/pipeline/accumulator_avg.cpp:43",
	"code" : 0,
	"ok" : 0
}

Note that both stages in the pipeline work by themselves and should return each document unmodified. Also, the combined aggregation works when running on a single server.



 Comments   
Comment by auto [ 20/Jul/12 ]

Author:

{u'date': u'2012-07-09T12:55:14-07:00', u'email': u'dannenberg.matt@gmail.com', u'name': u'Matt Dannenberg'}

Message: SERVER-6179 support multiple $group in sharded agg
Branch: master
https://github.com/mongodb/mongo/commit/dc0b517d81bc01565e3819493c7379182b5625b3

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