Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-6179

Sharded aggregation can't handle multiple $group commands

    XMLWordPrintableJSON

Details

    • ALL

    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.

      Attachments

        Activity

          People

            matt.dannenberg Matt Dannenberg
            mathias@mongodb.com Mathias Stearn
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: