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

WT RecoveryUnit can see effects of prepared transactions before commit

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Storage
    • Labels:
      None
    • Storage Execution
    • ALL
    • Hide
      (function() {
          "use strict";
          load("jstests/core/txns/libs/prepare_helpers.js");    
      
          const dbName = "test";
          const collName = "fast_count_sees_prepare_changes_before_commit";
          const testDB = db.getSiblingDB(dbName);
          const testColl = testDB.getCollection(collName);
          
          testColl.drop({writeConcern: {w: "majority"}});
          assert.commandWorked(testDB.runCommand({create: collName, writeConcern: {w: "majority"}}));
      
          const session = db.getMongo().startSession({causalConsistency: false});
          const sessionDB = session.getDatabase(dbName);
          const sessionColl = sessionDB.getCollection(collName);    
          const doc = {x: 1};    
      
          session.startTransaction();
          assert.commandWorked(sessionColl.insert(doc));
          PrepareHelpers.prepareTransaction(session);    
          assert.eq(testColl.find().itcount(), 0, () => tojson(testColl.find().toArray()));
          assert.eq(testColl.count(), 1, () => tojson(testColl.stats()));    session.abortTransaction_forTesting();
          assert.eq(testColl.find().itcount(), 0, () => tojson(testColl.find().toArray()));
          assert.eq(testColl.count(), 0, () => tojson(testColl.stats()));
      }());
      Show
      (function() { "use strict"; load("jstests/core/txns/libs/prepare_helpers.js"); const dbName = "test"; const collName = "fast_count_sees_prepare_changes_before_commit"; const testDB = db.getSiblingDB(dbName); const testColl = testDB.getCollection(collName); testColl.drop({writeConcern: {w: "majority"}}); assert.commandWorked(testDB.runCommand({create: collName, writeConcern: {w: "majority"}})); const session = db.getMongo().startSession({causalConsistency: false}); const sessionDB = session.getDatabase(dbName); const sessionColl = sessionDB.getCollection(collName); const doc = {x: 1}; session.startTransaction(); assert.commandWorked(sessionColl.insert(doc)); PrepareHelpers.prepareTransaction(session); assert.eq(testColl.find().itcount(), 0, () => tojson(testColl.find().toArray())); assert.eq(testColl.count(), 1, () => tojson(testColl.stats())); session.abortTransaction_forTesting(); assert.eq(testColl.find().itcount(), 0, () => tojson(testColl.find().toArray())); assert.eq(testColl.count(), 0, () => tojson(testColl.stats())); }());

      If we prepare a transaction and then call itcount() and count() on the collection outside of the associated session, we see two conflicting values. itcount() will not see the effects of a transaction in prepare, but count() will. 

      We should confirm whether or not we expect this behavior.

            Assignee:
            backlog-server-execution [DO NOT USE] Backlog - Storage Execution Team
            Reporter:
            pavithra.vetriselvan@mongodb.com Pavithra Vetriselvan
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: