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

$group does not track memory usage

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.5.1
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • Labels:
      None

      Observed behavior: There is no bound on the amount of memory used by $group.
      Expected behavior: $group errors out if it consumes over 10% of physical ram (the same behavior as $sort).

      Test

      c = db.c;
      c.drop();
      
      big = new Array( 10000 + 1 ).toString();
      
      for( i = 0; i < 100000; ++i ) {
          c.save( { a:i, b:big } );
      }
      
      // Errs out due to running out of memory.
      printjson( c.aggregate( { $sort:{ a:1 } }, { $limit:1 } ) );
      
      // Does not err out.
      printjson( c.aggregate( { $group:{ _id:'$a', c:{ $addToSet:'$b' } } }, { $limit:1 } ) );
      

            Assignee:
            mathias@mongodb.com Mathias Stearn
            Reporter:
            aaron Aaron Staple
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: