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

tailable cursors should obey negative ntoreturn

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Major - P3 Major - P3
    • None
    • 2.6.8, 3.0.1
    • Querying
    • Query
    • ALL

    Description

      For regular (non-tailable) cursors, a negative ntoreturn value instructs the server to generate at most one batch of results. After generating the first batch, the server is expected to close the cursor and pass a cursorid of 0 back to the client.

      The server ignores that the ntoreturn value is negative for tailable cursors, and is willing to send multiple batches of results (i.e. at least one getMore) back to the client. You can reproduce this behavior with the script below:

      // Increase logLevel so that the logs indicate when a getMore occurs.
      db.adminCommand({setParameter: 1, logLevel: 1});
       
      t = db.t;
      t.drop();
      db.createCollection("t", {capped: true, size: 2048});
      t.insert({a: 1});
       
      var cursor = t.find().addOption(DBQuery.Option.tailable).limit(-3);
      cursor.next();
       
      t.insert({a: 1});
      cursor.next(); // This triggers a getMore, but it should not.
      

      Attachments

        Activity

          People

            backlog-server-query Backlog - Query Team (Inactive)
            david.storch@mongodb.com David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: