ExportXMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Storage Execution
    • ALL
    • Hide
      import {configureFailPoint} from "jstests/libs/fail_point_util.js";
      import {waitForCurOpByFilter} from "jstests/libs/curop_helpers.js";
      import {after, afterEach, before, describe, it} from "jstests/libs/mochalite.js";
      import {ReplSetTest} from "jstests/libs/replsettest.js";
      
      describe("commit interrupted by a session kill", function() {
          const rst = new ReplSetTest({nodes: 2});
          let fp;
      
          before(function() {
              rst.startSet();
              rst.initiate();
          });
          after(function() {
              rst.stopSet();
          });
          afterEach(function() {
              if (fp) {
                  fp.off();
                  fp = null;
              }
          });
      
          it("does not report a writeConcernError on a committed transaction", function() {
              const primary = rst.getPrimary();
              const admin = primary.getDB("admin");
              fp = configureFailPoint(primary, "hangBeforeWaitingForWriteConcern");
      
              const awaitCommit = startParallelShell(`
                  const testDb = db.getSiblingDB("test");
                  const lsid = {id: UUID()};
                  const txnNumber = NumberLong(1);
                  assert.commandWorked(testDb.runCommand({
                      insert: "miniRepro",
                      documents: [{_id: 1}],
                      lsid: lsid,
                      txnNumber: txnNumber,
                      startTransaction: true,
                      autocommit: false,
                  }));
                  // This commit succeeds but pauses on the failpoint before its write-concern wait.
                  // commitTransaction may only be run against the admin database.
                  const res = assert.commandWorked(db.getSiblingDB("admin").runCommand({
                      commitTransaction: 1,
                      lsid: lsid,
                      txnNumber: txnNumber,
                      autocommit: false,
                      writeConcern: {w: "majority"},
                  }));
                  assert(!res.hasOwnProperty("writeConcernError"),
                         "committed transaction reported a writeConcernError", {res});
              `, primary.port);
      
              fp.wait({timesEntered: 1});
      
              // Interrupt the paused commit. killOp marks the operation killed through the same
              // killOperation -> markKilled path the cache-pressure session kill uses.
              const commitOp = waitForCurOpByFilter(admin, {"command.commitTransaction": {$exists: true}})[0];
              assert.commandWorked(admin.runCommand({killOp: 1, op: commitOp.opid}));
      
              // Resume the commit only once the interrupt has been delivered.
              waitForCurOpByFilter(
                  admin, {"command.commitTransaction": {$exists: true}, killPending: true});
      
              fp.off();
              fp = null;
              awaitCommit();
          });
      });
      
      Show
      import {configureFailPoint} from "jstests/libs/fail_point_util.js" ; import {waitForCurOpByFilter} from "jstests/libs/curop_helpers.js" ; import {after, afterEach, before, describe, it} from "jstests/libs/mochalite.js" ; import {ReplSetTest} from "jstests/libs/replsettest.js" ; describe( "commit interrupted by a session kill" , function () { const rst = new ReplSetTest({nodes: 2}); let fp; before( function () { rst.startSet(); rst.initiate(); }); after( function () { rst.stopSet(); }); afterEach( function () { if (fp) { fp.off(); fp = null ; } }); it( "does not report a writeConcernError on a committed transaction" , function () { const primary = rst.getPrimary(); const admin = primary.getDB( "admin" ); fp = configureFailPoint(primary, "hangBeforeWaitingForWriteConcern" ); const awaitCommit = startParallelShell(` const testDb = db.getSiblingDB( "test" ); const lsid = {id: UUID()}; const txnNumber = NumberLong(1); assert.commandWorked(testDb.runCommand({ insert: "miniRepro" , documents: [{_id: 1}], lsid: lsid, txnNumber: txnNumber, startTransaction: true , autocommit: false , })); // This commit succeeds but pauses on the failpoint before its write-concern wait. // commitTransaction may only be run against the admin database. const res = assert.commandWorked(db.getSiblingDB( "admin" ).runCommand({ commitTransaction: 1, lsid: lsid, txnNumber: txnNumber, autocommit: false , writeConcern: {w: "majority" }, })); assert(!res.hasOwnProperty( "writeConcernError" ), "committed transaction reported a writeConcernError" , {res}); `, primary.port); fp.wait({timesEntered: 1}); // Interrupt the paused commit. killOp marks the operation killed through the same // killOperation -> markKilled path the cache-pressure session kill uses. const commitOp = waitForCurOpByFilter(admin, { "command.commitTransaction" : {$exists: true }})[0]; assert.commandWorked(admin.runCommand({killOp: 1, op: commitOp.opid})); // Resume the commit only once the interrupt has been delivered. waitForCurOpByFilter( admin, { "command.commitTransaction" : {$exists: true }, killPending: true }); fp.off(); fp = null ; awaitCommit(); }); });
    • Storage Execution 2026-11-23
    • 0
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      A transaction that commits successfully can still report a writeConcernError(WCE) if a session kill delivered an interrupt to the committing operation before its majority write-concern wait completed. The interrupt is sticky and cannot be retracted, so the client receives ok: 1 with WCE on a transaction that is durably committed. Retrying the whole operation in response is unsafe because the write already committed.

      Why the error is not recoverable for clients as-is?

      TemporarilyUnavailable (365) carries no error categories therefore has no TransientTransactionError label and clients get no signal that only the commit needs retrying. A client that retries the whole operation after observing WCE 365 on a committed transaction will duplicate the write.

      Mechanisms that can trigger this

      Any session-kill path that interrupts a checked-out operation can deliver the interrupt inside the commit-to-write-concern-wait window:

      • Cache-pressure rollback thread. The periodic thread calls killOldestTransaction() with reason TemporarilyUnavailable (365) when the storage engine reports cache pressure (periodic_runner_cache_pressure_rollback.cpp). This is what produced BF-45709.
      • transactionLifetimeLimitSeconds killer. The same killSessionsAction machinery aborts long-running transactions with code 290 (kill_sessions_local.cpp).
      • User-issued session kills. killSessions and killAllSessions interrupt operations with reason Interrupted(kill_sessions_local.cpp).
      • killOp. Marks the target operation killed through the same killOperation() -> markKilled() path (operation_killer.cpp). This is what the attached reproducer uses.

            Assignee:
            Vishnu Kaushik
            Reporter:
            Ernesto Rodriguez Reina
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: