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

    XMLWordPrintableJSON

Details

    • Fully Compatible
    • ALL
    • v3.6
    • 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();
    • 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

        Activity

          People

            william.schultz@mongodb.com William Schultz (Inactive)
            robert.guo@mongodb.com Robert Guo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: