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

$type results are inconsistent with indexing enable on Infinity, -Infinity, NaN

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 2.2.7, 2.4.14, 2.6.10, 3.1.5
    • Fix Version/s: 3.1.7
    • Component/s: Index Maintenance, Querying
    • Labels:
    • Backwards Compatibility:
      Minor Change
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      In the shell:

      > db.test.insert({ a: Infinity })
      WriteResult({ "nInserted" : 1 })
      > db.test.find({ a : { $type : 1 }})
      { "_id" : ObjectId("559edd0837a9ccb7245bb7fd"), "a" : Infinity }
      > db.test.ensureIndex({ a : 1})
      {
              "createdCollectionAutomatically" : false,
              "numIndexesBefore" : 1,
              "numIndexesAfter" : 2,
              "ok" : 1
      }
      > db.test.find({ a : { $type : 1 }})
      > db.test.dropIndex({ a : 1 })
      { "nIndexesWas" : 2, "ok" : 1 }
      > db.test.find({ a : { $type : 1 }})
      { "_id" : ObjectId("559edd0837a9ccb7245bb7fd"), "a" : Infinity }
      

      Show
      In the shell: > db.test.insert({ a: Infinity }) WriteResult({ "nInserted" : 1 }) > db.test.find({ a : { $type : 1 }}) { "_id" : ObjectId("559edd0837a9ccb7245bb7fd"), "a" : Infinity } > db.test.ensureIndex({ a : 1}) { "createdCollectionAutomatically" : false, "numIndexesBefore" : 1, "numIndexesAfter" : 2, "ok" : 1 } > db.test.find({ a : { $type : 1 }}) > db.test.dropIndex({ a : 1 }) { "nIndexesWas" : 2, "ok" : 1 } > db.test.find({ a : { $type : 1 }}) { "_id" : ObjectId("559edd0837a9ccb7245bb7fd"), "a" : Infinity }

      Description

      Executing a type query with indexing and without can result in different results for Infinity, -Infinity, NaN.

      The issue is in src/mongo/db/query/index_bounds_builder.cpp and caused by implementation of BSONElement.appendMin/MaxForType.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              david.hatch David Hatch
              Reporter:
              david.hatch David Hatch
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: