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

$bucketAuto does not account the memory used while running accumulator

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.8.0
    • Affects Version/s: None
    • Component/s: None
    • Fully Compatible
    • ALL
    • Hide
      coll.drop();
      for (let i = 0; i < 500; ++i) {
          for (let j = 0; j < 10; ++j) {
              assert.commandWorked(coll.insert({groupBy: i}));
          }
      }
      
      const res = coll.aggregate([
                    {
                        $bucketAuto: {
                            groupBy: "$groupBy",
                            buckets: 500,
                           // This should create an array of 10MB size for each group, resulting in 5GB of memory usage overall.
                            output: {arr: {$push: "a".repeat(1000000)}} 
                        }
                    },
                    {$count: "c"}
                ])
                .toArray();
      
      Show
      coll.drop(); for (let i = 0; i < 500; ++i) { for (let j = 0; j < 10; ++j) { assert .commandWorked(coll.insert({groupBy: i})); } } const res = coll.aggregate([ { $bucketAuto: { groupBy: "$groupBy" , buckets: 500, // This should create an array of 10MB size for each group, resulting in 5GB of memory usage overall. output: {arr: {$push: "a" .repeat(1000000)}} } }, {$count: "c" } ]) .toArray();
    • Query 2020-08-24, Query 2020-09-07, Query 2020-09-21
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      We account the memory used while running the sorter but not when running the accumulator. This could result in server consuming unlimited amount of memory while executing an aggregate command.

            Assignee:
            arun.banala@mongodb.com Arun Banala
            Reporter:
            arun.banala@mongodb.com Arun Banala
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: