[SERVER-279] Multi-key indexes with empty arrays may cause incorrect results on queries that don't use the full index Created: 04/Sep/09 Updated: 12/Jul/16 Resolved: 08/Oct/09 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Index Maintenance |
| Affects Version/s: | 1.0.0 |
| Fix Version/s: | 1.1.2 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Frank Swiderski | Assignee: | Eliot Horowitz (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Any, git hash 644df81d2167628a7a9494a1953f981d148ebfbb |
||
| Issue Links: |
|
||||||||
| Participants: | |||||||||
| Description |
|
If you create a multi-key index that has documents omitted because they have null values or empty arrays, mongo may return incorrect results on other queries that attempt to use part of that index. The query planner will use a multi-key index (take, for example, an index with keys: k0, k1) if you run a query that matches part of the index (for example, searching on k0). However, if some documents are missing because criteria unrelated to the current query causes them to be excluded from the index (for example, where k1 is an array, and the document has an empty array), then searching just on the partial index will not return all documents that should have matched. Repro follows: MongoDB shell version: 1.1.0- ); ); ); {"_id" : ObjectId( "4aa09b10fce2291061418fb1") , "id" : 1 , "info" : [] , "str" : "hi"} {"_id" : ObjectId( "4aa09b1bfce2291061418fb2") , "id" : 1 , "info" : ["foo"] , "str" : "hi"}> db.party.ensureIndex( {id:1,info:1}); ); {"_id" : ObjectId( "4aa09b1bfce2291061418fb2") , "id" : 1 , "info" : ["foo"] , "str" : "hi"}> db.party.dropIndexes(); {"nIndexesWas" : 2 , "msg" : "all indexes deleted for collection" , "ok" : 1}> db.party.ensureIndex( {id:1}); ); {"_id" : ObjectId( "4aa09b10fce2291061418fb1") , "id" : 1 , "info" : [] , "str" : "hi"} {"_id" : ObjectId( "4aa09b1bfce2291061418fb2") , "id" : 1 , "info" : ["foo"] , "str" : "hi"} |
| Comments |
| Comment by Eliot Horowitz (Inactive) [ 16/Oct/09 ] |
|
release 10/16/2009 |
| Comment by Eliot Horowitz (Inactive) [ 07/Oct/09 ] |
|
added a specific test jstests/multi2.js |
| Comment by Eliot Horowitz (Inactive) [ 06/Sep/09 ] |
|
|