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

Matcher returns false positives in comparison predicates with MinKey/MaxKey

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.1.1
    • Component/s: Querying
    • Labels:
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v4.0, v3.6
    • Sprint:
      Query 2018-07-02, Query 2018-07-16

      Description

      For any field "a", the matcher falsely considers all documents (with the exception of {a: MaxKey} and {a: MinKey}) as matching the following predicates:

      {a: {$gt: MaxKey}}
      {a: {$gte: MaxKey}}
      {a: {$lt: MinKey}}
      {a: {$lte: MinKey}}
      

      Reproduce with the following shell snippet. The assertion on the last line fails.

      db.foo.drop();
      db.foo.insert({a: 1});
      db.foo.ensureIndex({a: 1});
      assert.eq(0, db.foo.find({a: {$gt: MaxKey}}).itcount()); // Passes as expected.
      db.foo.dropIndexes();
      assert.eq(0, db.foo.find({a: {$gt: MaxKey}}).itcount()); // Fails: itcount() returns 1.
      

      This is a regression introduced in 2.3.0 by e1085e54 (SERVER-3104). Affects all versions released since.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              minji.kim Minji Kim
              Reporter:
              rassi J Rassi
              Participants:
              Votes:
              2 Vote for this issue
              Watchers:
              16 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: