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

Segmentation fault when trying to use $bucketAuto with $max or $min operator in the output field

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.4.1
    • Component/s: Aggregation Framework
    • None
    • ALL
    • Hide
      var d = db.getSiblingDB('test');
      
      d.drop();
      d.foo.insertMany([
        { number_of_employees: 10 },
        { number_of_employees: 50 },
        { number_of_employees: 1 },
        { number_of_employees: 100 },
        { number_of_employees: 101 },
        { number_of_employees: 150 },
        { number_of_employees: 9203 },
        { number_of_employees: 100 },
        { number_of_employees: 1212 }
      ]);
      
      d.foo.aggregate([
        {'$bucketAuto': {
          'groupBy': '$number_of_employees',
          'buckets': 3,
          'output': { 'value': { '$max': '$number_of_employees' } }
        }}
      ]);
      
      Show
      var d = db.getSiblingDB( 'test' ); d.drop(); d.foo.insertMany([ { number_of_employees: 10 }, { number_of_employees: 50 }, { number_of_employees: 1 }, { number_of_employees: 100 }, { number_of_employees: 101 }, { number_of_employees: 150 }, { number_of_employees: 9203 }, { number_of_employees: 100 }, { number_of_employees: 1212 } ]); d.foo.aggregate([ { '$bucketAuto' : { 'groupBy' : '$number_of_employees' , 'buckets' : 3, 'output' : { 'value' : { '$max' : '$number_of_employees' } } }} ]);

      It seems that using $max or $min in the output option of a $bucketAuto aggregation step triggers a segmentation fault. I managed to reproduce this issue with version 3.4.1-ent, and this script (replace $max by $min, to have the same behaviour):

      var d = db.getSiblingDB('test');
      
      d.drop();
      d.foo.insertMany([
        { number_of_employees: 10 },
        { number_of_employees: 50 },
        { number_of_employees: 1 },
        { number_of_employees: 100 },
        { number_of_employees: 101 },
        { number_of_employees: 150 },
        { number_of_employees: 9203 },
        { number_of_employees: 100 },
        { number_of_employees: 1212 }
      ]);
      
      d.foo.aggregate([
        {'$bucketAuto': {
          'groupBy': '$number_of_employees',
          'buckets': 3,
          'output': { 'value': { '$max': '$number_of_employees' } }
        }}
      ]);
      

      Output:

      2017-01-04T14:56:55.963+0100 E QUERY    [main] Error: error doing query: failed: network error while attempting to run command 'aggregate' on host '127.0.0.1:27017'  :
      DB.prototype.runCommand@src/mongo/shell/db.js:132:1
      DB.prototype.runReadCommand@src/mongo/shell/db.js:109:16
      DBCollection.prototype._dbReadCommand@src/mongo/shell/collection.js:183:12
      DBCollection.prototype.aggregate/doAgg<@src/mongo/shell/collection.js:1298:30
      DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1301:15
      @(shell):1:1
      

      The logs are attached to this ticket.

        1. segfault_bucketAuto_max.log
          20 kB
          Charles Sarrazin

            Assignee:
            Unassigned Unassigned
            Reporter:
            charles.sarrazin@mongodb.com Charles Sarrazin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: