[SERVER-18341] Matcher returns false positives in comparison predicates with MinKey/MaxKey Created: 06/May/15  Updated: 19/Aug/20  Resolved: 02/Jul/18

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: 4.1.1, 4.0.21

Type: Bug Priority: Major - P3
Reporter: J Rassi Assignee: Minji Kim
Resolution: Done Votes: 2
Labels: QFB, neweng, storch
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Duplicate
is duplicated by SERVER-33877 Inconsistent results when using MinKe... Closed
Related
related to SERVER-11369 Change in behaviour of MinKey/MaxKey Closed
related to SERVER-3104 index bound improvements for elemMatc... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.0, v3.6
Sprint: Query 2018-07-02, Query 2018-07-16
Participants:

 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.



 Comments   
Comment by Githook User [ 14/Aug/20 ]

Author:

{'name': 'Minji', 'email': 'minjikim0202@gmail.com', 'username': 'minjikim0202'}

Message: SERVER-18341 Matcher returns false positives in comparison predicates with MinKey/MaxKey

(cherry picked from commit b5291b87ab3350bff9bd9ef4464a63dcda81ac21)
Branch: v4.0
https://github.com/mongodb/mongo/commit/d5e2742489c6502f68324c5e40d4ea78c01a3dad

Comment by Githook User [ 02/Jul/18 ]

Author:

{'username': 'minjikim0202', 'name': 'Minji', 'email': 'minjikim0202@gmail.com'}

Message: SERVER-18341 Matcher returns false positives in comparison predicates with MinKey/MaxKey
Branch: master
https://github.com/mongodb/mongo/commit/b5291b87ab3350bff9bd9ef4464a63dcda81ac21

Comment by James Lindberg [ 26/Oct/17 ]

Is there any update on this? It is quite alarming behavior given how unambiguous the documentation is:
https://docs.mongodb.com/manual/reference/operator/query/type/#minkey-and-maxkey

If this issue will not be fixed, could the documentation be updated?

Generated at Thu Feb 08 03:47:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.