[SERVER-17011] Cursor can return objects out of order if updated during query ("legacy" readMode only) Created: 22/Jan/15  Updated: 20/Nov/16  Resolved: 21/Dec/15

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.6.7, 2.8.0-rc5
Fix Version/s: 3.2.3, 3.3.0

Type: Bug Priority: Major - P3
Reporter: Charlie Swanson Assignee: David Storch
Resolution: Done Votes: 0
Labels: code-and-test
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-17577 Allow the query system to make use of... Closed
Related
related to SERVER-12438 batch size with an unindexed sort in ... Closed
related to SERVER-20815 Remove yield_sort.js workload from FS... Closed
is related to SERVER-19996 Queries which specify sort and batch ... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Completed:
Steps To Reproduce:

var t = db.foo;                                                                                        
t.drop();                                                                                              
t.ensureIndex({a: 1, b: 1});                                                                           
t.insert({a: 1, b: 3});                                                                                
t.insert({a: 2, b: 2});                                                                                
t.insert({a: 3, b: 1});                                                                                
                                                                                                       
var cur = t.find({a: {$lt: 4}}).sort({b: -1}).batchSize(2);                                            
printjson(cur.next());                                                                                 
printjson(cur.next());                                                                                 
                                                                                                       
t.update({b: 1}, {$set: {b: 4}});                                                                      
                                                                                                       
printjson(cur.next());  // prints {a: 3, b: 4}, which is out of order

Sprint: QuInt A (10/12/15), QuInt B (11/02/15), QuInt C (11/23/15), QuInt E (01/11/16)
Participants:

 Description   

Happens on 2.6.7, and 2.8.rc6, both WT and MMAPV1. See steps to reproduce.

This bug is specific to --readMode "legacy"; it will not happen with --readMode "commands" (i.e. if you have a 3.2 server and an updated-for-3.2 driver).



 Comments   
Comment by Githook User [ 11/Jan/16 ]

Author:

{u'username': u'dstorch', u'name': u'David Storch', u'email': u'david.storch@10gen.com'}

Message: SERVER-17011 add EnsureSorted stage

Preserves the sort order for 'ntoreturn hack' plans.

(cherry picked from commit 56dba2953b622efcae75d7bd9b6aa4154dd25d34)
Branch: v3.2
https://github.com/mongodb/mongo/commit/c210b9c6dac21643a0b098590f3c62f36f7afbf3

Comment by Githook User [ 21/Dec/15 ]

Author:

{u'username': u'dstorch', u'name': u'David Storch', u'email': u'david.storch@10gen.com'}

Message: SERVER-17011 add EnsureSorted stage

Preserves the sort order for 'ntoreturn hack' plans.
Branch: master
https://github.com/mongodb/mongo/commit/56dba2953b622efcae75d7bd9b6aa4154dd25d34

Comment by David Storch [ 13/May/15 ]

I have confirmed that the patch for SERVER-17577 fixes this problem, assuming that the query is issued with a find command rather than using a traditional OP_QUERY style find. Resolving as a duplicate.

EDIT: We have re-opened this ticket in order to evaluate whether we can produce a targeted fix suitable for backport. The fix via the find command will only be available with a version 3.2 cluster plus an upgraded driver that supports 3.2 features.

Comment by David Storch [ 23/Jan/15 ]

Introduced by handling of limit/batchSize ambiguity added in SERVER-12438. This will be fixed by the introduction of the find command (see SERVER-15176), although we should consider an interim fix.

EDIT: The work to resolve this by adding a limit to the find command is currently in progress under SERVER-17577 (a subtask of SERVER-15176: "New commands for find and getMore").

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