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

Bugs from SERVER-84488 block processing buildBlockAccumulatorSum()

    • Type: Icon: Bug Bug
    • Resolution: Gone away
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Execution
    • ALL

      SERVER-84488 delivered a new method buildBlockAccumulatorSum() that injected some bugs. It also does not make $sum work in block processing mode (though the ticket was officially about making $count work in block processing mode, so maybe that bit was expected).

      Reproduction (requires featureFlagSbeFull)

      These repros are from master branch SHA f726b6db from 2024-03-01, which is four commits after SERVER-84488's commit d2663eca, also from 2024-03-01, that injected the issues.

      0. Setup

      db.coll.drop()
      db.createCollection("coll", {timeseries: {timeField: "t"}})
      db.coll.insert({t: new Date(), a: 4, b: 7, c: 5})
      db.coll.insert({t: new Date(), a: 2, b: 9, c: 8})
      db.coll.insert({t: new Date(), a: 3, b: 1, c: 6})
      

      1. {$sum: "$a"} does NOT use block processing mode, because buildBlockAccumulatorSum() returns an empty vector unless the argument to $sum is a constant. Thus the caller falls back to the existing row-based $sum accumulator and gets the correct answer, but it may be a bug that it did not use block processing mode:

      > db.coll.aggregate([{$project: {a: 1}},
          {$group: {_id: null, x: {$sum : "$a"}}}], {allowDiskUse: false})
      
      { "_id" : null, "x" : 9 }
      

      2. {$sum: 10} DOES use block processing mode, but gives wrong results (the sum of three 10s should be 30 but comes out as 10):

      > db.coll.aggregate([{$project: {a: 1}},
          {$group: {_id: null, x: {$sum : 10}}}], {allowDiskUse: false})
      
      { "_id" : null, "x" : 10 }
      

      3. {$sum: "10"} (arg is a non-numeric constant) DOES use block processing mode but results in the server core dumping in the SBE VM:

      > db.coll.aggregate([{$project: {a: 1}},
          {$group: {_id: null, x: {$sum : "10"}}}], {allowDiskUse: false})
      
      Error: network error while attempting to run command 'aggregate' on host '127.0.0.1:27017'  :: caused by :: dbclient error communicating with server 127.0.0.1:27017 :: caused by :: futurize :: caused by :: Connection closed by peer :
      Mongo.prototype.runCommand@src/mongo/shell/mongo.js:163:17
      runClientFunctionWithRetries@src/mongo/shell/session.js:348:42
      runCommand@src/mongo/shell/session.js:465:53
      DB.prototype._runCommandImpl@src/mongo/shell/db.js:163:45
      DB.prototype.runCommand@src/mongo/shell/db.js:178:21
      DB.prototype.runReadCommand@src/mongo/shell/db.js:157:17
      DB.prototype._runAggregate@src/mongo/shell/db.js:264:22
      DBCollection.prototype.aggregate@src/mongo/shell/collection.js:985:21
      @(shell):1:9
      

            Assignee:
            ian.boros@mongodb.com Ian Boros
            Reporter:
            kevin.cherkauer@mongodb.com Kevin Cherkauer
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: