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

Inconsistency between the classic engine and SBE: {$mod: [-Infinity, NumberLong("0")]}

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Duplicate
    • 5.0.0-rc6
    • None
    • None
    • ALL
    • Query Execution 2021-07-12
    • 28

    Description

      Based on BF-21717, here's a minimal example to reproduce the issue:

      > db.col.drop();
      true
      > db.col.insert({_id: 590, "obj": {_id: 595, "obj": {_id: 596, "num": Infinity }, }, });
      WriteResult({ "nInserted" : 1 })
      > db.col.find();
      { "_id" : 590, "obj" : { "_id" : 595, "obj" : { "_id" : 596, "num" : Infinity } } }
      > // using the classic engine
      > db.adminCommand({setParameter: 1, internalQueryEnableSlotBasedExecutionEngine: false})
      { "was" : true, "ok" : 1 }
      > db.col.aggregate([{$match: {"obj.obj.num": {$mod: [-Infinity, NumberLong("0")]}}}]);
      { "_id" : 590, "obj" : { "_id" : 595, "obj" : { "_id" : 596, "num" : Infinity } } }
      > // using SBE
      > db.adminCommand({setParameter: 1, internalQueryEnableSlotBasedExecutionEngine: true})
      { "was" : false, "ok" : 1 }
      > db.col.aggregate([{$match: {"obj.obj.num": {$mod: [-Infinity, NumberLong("0")]}}}]);
      >
      

      Even if you change -Infinity with Infinity in the above query, result is the same:

      > db.col.drop();
      true
      > db.col.insert({_id: 590, "obj": {_id: 595, "obj": {_id: 596, "num": Infinity }, }, });
      WriteResult({ "nInserted" : 1 })
      > db.col.find();
      { "_id" : 590, "obj" : { "_id" : 595, "obj" : { "_id" : 596, "num" : Infinity } } }
      > // using the classic engine
      > db.adminCommand({setParameter: 1, internalQueryEnableSlotBasedExecutionEngine: false})
      { "was" : true, "ok" : 1 }
      > db.col.aggregate([{$match: {"obj.obj.num": {$mod: [Infinity, NumberLong("0")]}}}]);
      { "_id" : 590, "obj" : { "_id" : 595, "obj" : { "_id" : 596, "num" : Infinity } } }
      > // using SBE
      > db.adminCommand({setParameter: 1, internalQueryEnableSlotBasedExecutionEngine: true})
      { "was" : false, "ok" : 1 }
      > db.col.aggregate([{$match: {"obj.obj.num": {$mod: [Infinity, NumberLong("0")]}}}]);
      > 
      

      As you see in the above example, the classic engine considers the result of either {$mod: [-Infinity, NumberLong("0")]} or {$mod: [Infinity, NumberLong("0")]} to be Infinity. However, SBE does not match the result of either {$mod: [-Infinity, NumberLong("0")]} or {$mod: [Infinity, NumberLong("0")]} with Infinity. That's why, the classic engine passes the tuple through its filter, but SBE doesn't do the same. It's best if we could fix either of these engine to avoid this difference. This difference is specially annoying in the fuzzer tests, but not sure about its impact on the real-world scenarios.

      Attachments

        Issue Links

          Activity

            People

              mindaugas.malinauskas@mongodb.com Mindaugas Malinauskas
              mohammad.dashti@mongodb.com Mohammad Dashti
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: