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

$avg with Infinity can incorrectly return NaN

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Backlog
    • Component/s: None
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      *On a debug build, to ensure we always spill to disk*

      db.test.insert({_id: 0, value: Infinity});
      db.test.insert({_id: 0, value: 5});
      db.test.aggregate([{ $group: {
                      _id: null,
                      'num': { 
                          $avg: '$value'
                      }
      } }]);
      

      Show
      * On a debug build, to ensure we always spill to disk * db.test.insert({_id: 0, value: Infinity}); db.test.insert({_id: 0, value: 5}); db.test.aggregate([{ $group: { _id: null, 'num': { $avg: '$value' } } }]);
    • Linked BF Score:
      50

      Description

      When adding Infinity to any value using the DoubleDoubleSummation class, the _addend double is calculated to be NaN. This is probably fine, however getting the result of the summation here results in a value of Infinity with an error of NaN.

      If this happens when the $avg accumulator spills to disk, we will attempt to process the NaN error as if its a finite value and as a result the accumulator evaluates to NaN.

        Attachments

          Activity

            People

            Assignee:
            backlog-query-optimization Backlog - Query Optimization
            Reporter:
            nicholas.zolnierz Nicholas Zolnierz
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated: