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

A cursor with the "exhaust" option does not return documents inserted in the same txn

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 3.7.9
    • Fix Version/s: 3.6.9, 4.0.0-rc0
    • Component/s: Querying, Replication
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v3.6
    • Steps To Reproduce:
      Hide

      /*
       * Setup cluster.
       */
      var r = new ReplSetTest({nodes:2});
      r.startSet();r.initiate();
       
      var dbName = 'test';
      var collName = 'test';
       
      const sessionOptions = {causalConsistency: false};
      const session = r.getPrimary().startSession(sessionOptions);
      const sessionDb = session.getDatabase(dbName);
      const sessionColl = sessionDb.getCollection(collName);
       
      assert.commandWorked(sessionDb.runCommand({create: collName, writeConcern: {w: "majority"}}));
      r.awaitLastOpCommitted();
       
      /*
       * Repro
       */
       
      session.startTransaction();
       
      assert.writeOK(sessionColl.insert({a: 1}));
      assert.eq(sessionColl.find().addOption(DBQuery.Option.exhaust).itcount(), 1);
       
      session.commitTransaction();
      session.endSession();
      

      Show
      /* * Setup cluster. */ var r = new ReplSetTest({nodes:2}); r.startSet();r.initiate();   var dbName = 'test' ; var collName = 'test' ;   const sessionOptions = {causalConsistency: false }; const session = r.getPrimary().startSession(sessionOptions); const sessionDb = session.getDatabase(dbName); const sessionColl = sessionDb.getCollection(collName);   assert.commandWorked(sessionDb.runCommand({create: collName, writeConcern: {w: "majority" }})); r.awaitLastOpCommitted();   /* * Repro */   session.startTransaction();   assert.writeOK(sessionColl.insert({a: 1})); assert.eq(sessionColl.find().addOption(DBQuery.Option.exhaust).itcount(), 1);   session.commitTransaction(); session.endSession();
    • Sprint:
      Repl 2018-05-21

      Description

      The batch size, number of inserted documents, and whether there are existing documents in the collection do not seem to matter. See repro for more detail.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              william.schultz William Schultz (Inactive)
              Reporter:
              robert.guo Robert Guo
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: