[DRIVERS-241] Change in getMore behavior in 3.2 Created: 25/Jun/15  Updated: 30/Aug/16  Resolved: 30/Aug/16

Status: Closed
Project: Drivers
Component/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Christian Amor Kvalheim Assignee: Unassigned
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

There is a change in behavior coming up in 3.2 related to the ticket.

https://jira.mongodb.org/browse/SERVER-2454

If you overwrite the current position of a tailable cursor in a capped collection in 3.0 or earlier it will just return you an empty result on the next getmore. In 3.2 this will cause it to return an error.

[

{ ok: 0, errmsg: 'GetMore command executor error: InternalError CollectionScan died: Unexpected RecordId', code: 96 }

]

Code speaks a thousand words so I've included the code causing this in ndoe.js.

I'm not sure what kind of impact this code will have on applications so I'm putting in this ticket to get some feedback.

    // http://www.mongodb.org/display/DOCS/Tailable+Cursors
    var db = configuration.newDbInstance(configuration.writeConcernMax(), {poolSize:1, auto_reconnect:false});
 
    db.open(function(err, db) {
 
      var options = { capped: true, size: 8 };
      db.createCollection('test_if_dead_tailable_cursors_close', options, function(err, collection) {
        test.equal(null, err);
        var closed = false;
        var stream = collection.find({}, { tailable: true }).stream();
 
        // Just hammer the server
        for(var i = 0; i < 1000; i++) {
          collection.insert({id: i});
        }
 
        stream.on('data', function (doc) {
          console.log("--------------------------- got data")
          console.dir(doc)
        });
 
        stream.on('error', function (err) {
          console.log("--------------------------- got error")
          test.ok(err != null);
        });
 
        stream.on('close', function () {
          console.log("--------------------------- close")
          // this is what we need
          closed = true;
        });
 
        // Just hammer the server
        for(var i = 0; i < 10000; i++) {
          process.nextTick(function() {
            collection.insert({id: i});
          })
        }
 
        setTimeout(function () {
          db.close();
          test.equal(true, closed);
          db.close();
          test.done();
        }, 800);
      });
    });



 Comments   
Comment by Dana Groff [ 30/Aug/16 ]

great; go for it.

Dana Groff
dana.groff@mongodb.com

Generated at Thu Feb 08 08:21:04 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.