[SERVER-10725] incorrect results from $ne query using sparse index Created: 10/Sep/13 Updated: 11/Jul/16 Resolved: 07/Nov/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | 2.4.6, 2.4.7, 2.5.3 |
| Fix Version/s: | 2.5.4 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Christophe Pizzuti | Assignee: | hari.khalsa@10gen.com |
| Resolution: | Done | Votes: | 1 |
| Labels: | $ne, query, query_triage | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Linux on PC |
||
| Attachments: |
|
| Operating System: | ALL |
| Steps To Reproduce: | Commands from a mongo shell db.user.drop() , {unique:1, safe:1}) , {sparse:1, safe:1}) , {unique:1, sparse:1, dropDups:1, safe:1}) , "applications" : [ { "application" : ObjectId("522f16d7594e4df1158b48f2"), "access_token" : "522f16d7594e4df1158b48f1|uac2_1", "refresh_token" : "uref2_1" }, { "application" : ObjectId("522f16d7594e4df1158b48f3"), "access_token" : "522f16d7594e4df1158b48f1|uac2_2", "refresh_token" : "uref2_2", "last_ip" : "1.1.1.1", "last_ip_date" : ISODate("2013-09-10T12:55:51.319Z") } ], "devices" : [ "unitmac2" ], "mail" : "unituser2@netatmo.com", "password" : "password" }) } }) |
| Participants: |
| Description |
|
I have a collection having PushCtx.credentials and _id indexes. } }) Adding hint({_id : 1}) makes the query work } }).hint({_id : 1}) { "_id" : ObjectId("522f16d7594e4df1158b48f1"), (...) }This is a problem for me, as I do have to perform an update on that query, and that hint does not work in such a case |
| Comments |
| Comment by a zhifan [ 11/Sep/13 ] |
|
Yes, you are right. according to the current code of isSimpleIdQuery, do we aim at some queries which only have _id=? condition, not ( _id=? and xxx ... ). I think only if the query part is not ( _id=? or ... ), we can return true at isSimpleIdQuery(). but That would be more work to do. |
| Comment by Eliot Horowitz (Inactive) [ 11/Sep/13 ] |
|
I think I see why that makes that query work, but its not doing the right thing. |
| Comment by a zhifan [ 11/Sep/13 ] |
|
Very interested in mongodb. seems the cause is function isSimpleIdQuery(). I can fix it with the following change:
/* if( i.more() ) if( strcmp("_id", e.fieldName()) != 0 ) if ( e.isSimpleType() ) // e.g. not something like { _id : { $gt : ... |
| Comment by Eliot Horowitz (Inactive) [ 11/Sep/13 ] |
|
Able to reproduce. |