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

$multiply operator may return with or w/o an error depending on whether pipeline optimisation is enabled

    XMLWordPrintable

    Details

    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v4.2, v4.0, v3.6
    • Sprint:
      Query 2019-09-09
    • Case:
    • Linked BF Score:
      0

      Description

      When pipeline optimization is enabled, the arguments to the $multiply operator can be re-arranged. In certain cases, when one of the arguments is Infinity (or NaN), this re-arrangement may result in an error. But when the pipeline optimization is disabled, the very same query returns without an error.

      For example,

      db.col.insert({num: Infinity})
      db.col.aggregate({$project: {a: {$multiply: [NumberDecimal(1), "$num"]}}})
      2019-08-09T11:32:49.176+0100 E  QUERY    [js] Error: command failed: {
              "ok" : 0,
              "errmsg" : "Can't coerce out of range value inf to long",
              "code" : 31109,
              "codeName" : "Location31109"
      }
      db.adminCommand({configureFailPoint: 'disablePipelineOptimization', mode: 'alwaysOn'})
      db.col.aggregate({$project: {a: {$multiply: [NumberDecimal(1), "$num"]}}})
      { "_id" : ObjectId("5d4d4ba7bf418d2f35ef7d3c"), "a" : NumberDecimal("Infinity") }
      

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: