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

$mod match expression incorrectly handles NaN, Infinity and large values

    XMLWordPrintable

    Details

    • Backwards Compatibility:
      Minor Change
    • Operating System:
      ALL
    • Backport Requested:
      v5.0, v4.4, v4.2, v4.0
    • Steps To Reproduce:
      Hide

      db.coll.remove({});
      db.coll.insert({
      		"_id" : 1000907,
      		"obj" : {
      			"obj" : {
      				"num" : NaN,
      			}
      		}
      	});
      db.coll.aggregate([
      	{
      		"$match" : {
      			"obj.obj.num" : {
      				"$mod" : [
      					NumberDecimal("9.999999999999999999999999999999999E+6144"),
      					NumberLong(0)
      				]
      			}
      		}
      	}
      ])
      

      Result:
      Classic: one document in "coll" collection.
      SBE: empty set of documents.

      Show
      db.coll.remove({}); db.coll.insert({ "_id" : 1000907, "obj" : { "obj" : { "num" : NaN, } } }); db.coll.aggregate([ { "$match" : { "obj.obj.num" : { "$mod" : [ NumberDecimal("9.999999999999999999999999999999999E+6144"), NumberLong(0) ] } } } ]) Result: Classic: one document in "coll" collection. SBE: empty set of documents.
    • Sprint:
      Query Execution 2021-07-12, Query Execution 2021-07-26, QE 2021-09-06
    • Linked BF Score:
      163

      Description

      In classic variant of query execution $mod match expression (ModMatchExpression) interprets dividend value NaN (double) as -9223372036854775808 64-bit integer. In SBE, on the other hand, NaN to 64-bit integer transformation results in Nothing.  Furthermore, NumberDecimal("9.999999999999999999999999999999999E+6144") gets interpreted as NumberLong("-9223372036854775808") (classic and SBE). Those two factors, when combined, give unexpected results.  Please see "Steps to Reproduce".

       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mihai.andrei Mihai Andrei
              Reporter:
              mindaugas.malinauskas Mindaugas Malinauskas
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: