[SERVER-49766] Indexed and non-indexed collections return different results for null query Created: 21/Jul/20  Updated: 29/Oct/23  Resolved: 03/Sep/20

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 4.7.0, 4.2.10, 4.4.2

Type: Bug Priority: Major - P3
Reporter: Ted Tuckman Assignee: Svilen Mihaylov (Inactive)
Resolution: Fixed Votes: 0
Labels: qopt-team
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
depends on SERVER-47382 Enable $not with arrays Closed
Problem/Incident
Related
related to SERVER-56468 Incorrect plan cache entry for {$ne: ... Closed
related to SERVER-51351 Complete TODO listed in SERVER-49766 Closed
is related to SERVER-45233 Indexed inequalities to arrays return... Closed
Backwards Compatibility: Minor Change
Operating System: ALL
Backport Requested:
v4.4, v4.2
Sprint: Query 2020-08-10, Query 2020-08-24, Query 2020-09-07, Query 2020-09-21
Participants:
Linked BF Score: 41

 Description   

The collection index has an index on the val field.

> db.index.find({val: {$not: {$gte: null}}})
> db.non.find({val: {$not: {$gte: null}}})
{ "_id" : ObjectId("5f16f0bb1fe2fb0ca7b13d12"), "val" : [ ] }
> db.index.find()
{ "_id" : ObjectId("5f16f0da1fe2fb0ca7b13d13"), "val" : [ ] }
{ "_id" : ObjectId("5f16ff661fe2fb0ca7b13d14"), "val" : null }
> db.non.find()
{ "_id" : ObjectId("5f16f0bb1fe2fb0ca7b13d12"), "val" : [ ] }
{ "_id" : ObjectId("5f16ff6d1fe2fb0ca7b13d15"), "val" : null }
> db.index.getIndexes()
[
        {
                "v" : 2,
                "key" : {
                        "_id" : 1
                },
                "name" : "_id_"
        },
        {
                "v" : 2,
                "key" : {
                        "val" : 1
                },
                "name" : "val_1"
        }
]
> db.non.getIndexes()
[ { "v" : 2, "key" : { "_id" : 1 }, "name" : "_id_" } ]

The problem is probably in this function complement, called from here 



 Comments   
Comment by Githook User [ 20/Oct/20 ]

Author:

{'name': 'Svilen Mihaylov', 'email': 'svilen.mihaylov@mongodb.com', 'username': 'smihaylov-mongodb'}

Message: SERVER-51351 Complete TODO listed in SERVER-49766
Branch: master
https://github.com/mongodb/mongo/commit/8956d6b4605943f49b982331cbdca0426cd3fd2e

Comment by Githook User [ 11/Sep/20 ]

Author:

{'name': 'Svilen Mihaylov', 'email': 'svilen.mihaylov@mongodb.com', 'username': 'smihaylov-mongodb'}

Message: SERVER-49766 Indexed and non-indexed collections return different results for null query
Branch: v4.2
https://github.com/mongodb/mongo/commit/d4df979785aeb6a6156601f56447de8fbcb375c5

Comment by Githook User [ 11/Sep/20 ]

Author:

{'name': 'Svilen Mihaylov', 'email': 'svilen.mihaylov@mongodb.com', 'username': 'smihaylov-mongodb'}

Message: SERVER-49766 Indexed and non-indexed collections return different results for null query
Branch: v4.4
https://github.com/mongodb/mongo/commit/6d9aef102ace05654f9009ddd348df9cf278efdb

Comment by Githook User [ 03/Sep/20 ]

Author:

{'name': 'Svilen Mihaylov', 'email': 'svilen.mihaylov@mongodb.com', 'username': 'smihaylov-mongodb'}

Message: SERVER-49766 Indexed and non-indexed collections return different results for null query
Branch: master
https://github.com/mongodb/mongo/commit/39ce43a37c0e9bcdbaf04bbe76e9a75fefec7dd3

Comment by Svilen Mihaylov (Inactive) [ 02/Sep/20 ]

http://mongodbcr.appspot.com/655270002

Comment by James Wahlin [ 21/Jul/20 ]

Moving to investigating to look into what a fix would look like.

Generated at Thu Feb 08 05:20:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.