[SERVER-14752] Btree cursor returns partial result without error if reIndex occurs during yield Created: 31/Jul/14  Updated: 26/Feb/16  Resolved: 26/Feb/16

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

Type: Bug Priority: Major - P3
Reporter: Bruce Lucas (Inactive) Assignee: Tess Avitabile (Inactive)
Resolution: Duplicate Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-2454 Queries that are killed during a yiel... Closed
Operating System: ALL
Participants:

 Description   

To reproduce, run setup(), then run reindex() and count() in parallel:

var n = 1000
 
function setup() {
    db.c.drop()
    for (var i=0; i<n; i++)
        db.c.insert({_id:i, x:i})
    db.getLastError()
}
 
function reindex() {
    for (;;) {
        db.c.reIndex()
        sleep(1)
    }
}
 
function count() {
    for (;;) {
        var nn = db.c.find().hint({_id:1}).batchSize(n).itcount()
        if (n != nn)
            print('expected', n, 'got', nn)
    }
}

  • As written above, with a large enough batchsize to avoid getmore, when the query yields it finishes without error and returns only a subset of the documents (which is always one less than a multiple of 128, the unit of work for yielding). If the query is not able to return full results it should return an error.
  • If the code is modified to use a small batch size so that getmores occurs, the query errors out with a CursorNotFound, which is acceptable.


 Comments   
Comment by David Storch [ 26/Feb/16 ]

It's not a dup of SERVER-13123, but it does look like a dup of SERVER-2454. james.wahlin already did a partial backport of SERVER-2454 to the 2.6 branch which will be available in 2.6.12. I confirmed that I can reproduce this issue on 2.6.11 but not on HEAD of the v2.6 branch. Closing as a duplicate of SERVER-2454.

Comment by Tess Avitabile (Inactive) [ 26/Feb/16 ]

Actually, this is not a dup of SERVER-13123. The error-checking is introduced in commit 4049c8328c98d8eb2b84fffca43ff4904e936909, which is the original implementation of find_cmd.cpp (it is then improved in d690653daadef98652e58131ade8b34114f86ab2). So it is not a simple backport. david.storch, do you think we should try to fix this?

Comment by Tess Avitabile (Inactive) [ 01/Feb/16 ]

Yes, it looks like a dup of SERVER-13123

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