Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-17011

Cursor can return objects out of order if updated during query ("legacy" readMode only)

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.2.3, 3.3.0
    • Affects Version/s: 2.6.7, 2.8.0-rc5
    • Component/s: Querying
    • Labels:
    • Fully Compatible
    • ALL
    • Hide
      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
      
      Show
      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
    • QuInt A (10/12/15), QuInt B (11/02/15), QuInt C (11/23/15), QuInt E (01/11/16)

      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).

            Assignee:
            david.storch@mongodb.com David Storch
            Reporter:
            charlie.swanson@mongodb.com Charlie Swanson
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: