[SERVER-4975] covered index projection may be improperly applied after index becomes multikey during yield Created: 15/Feb/12  Updated: 14/May/15  Resolved: 14/May/15

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

Type: Bug Priority: Major - P3
Reporter: Aaron Staple Assignee: David Storch
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-18476 In-progress queries may return incorr... Backlog
Related
related to SERVER-17678 IndexScan doesn't dedup if index beco... Closed
Operating System: ALL
Participants:

 Description   

We currently support projections for non multikey indexes, but not multikey indexes. If an index becomes multikey during a yield, we may return results that are not proper projections of actual documents. For example, if {a:[1,2]} is saved during a yield making the index {a:1} multikey we may return {a:1} and {a:2} even though there may not be any documents that should be projected to {a:1} or {a:2}.

This issue affects yielding in both query and get more.

A test demonstrating the issue will be pushed.



 Comments   
Comment by David Storch [ 28/Jan/15 ]

Simple repro script:

t = db.t;
t.drop();
t.ensureIndex({a: 1});
 
t.insert({a: 1});
t.insert({a: 2});
t.insert({a: 3});
 
var cursor = t.find({a: {$gte: 1}}, {_id: 0, a: 1}).batchSize(2);
 
cursor.next(); // Correct: returns {a: 1}
cursor.next(); // Correct: returns {a: 2}
 
// Insert while yielded for a getMore, making the index multikey.
t.insert({a: [4, 5]});
 
cursor.next(); // Correct: returns {a: 3}
cursor.next(); // INCORRECT: returns {a: 4}

Comment by auto [ 15/Feb/12 ]

Author:

{u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'}

Message: SERVER-4975 test
Branch: master
https://github.com/mongodb/mongo/commit/c44cd1464034021eed587189071f9281b157a770

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