Change in getMore behavior in 3.2

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Component/s: None
    • None

      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);
            });
          });
      

            Assignee:
            Unassigned
            Reporter:
            Christian Amor Kvalheim
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: