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

Forbid dropping config.transactions when there are prepared transactions

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.2.9, 4.4.1, 4.7.0
    • Affects Version/s: 4.2.7, 4.4.0-rc7
    • Component/s: Replication
    • None
    • Fully Compatible
    • ALL
    • v4.4, v4.2
    • Hide

      Update no_writes_to_config_transactions_with_prepared_transaction.js with the following diff, so that writes to config.transactions are performed without a session. The update and delete fail correctly, but the drop does not fail as expected.

      diff --git a/jstests/core/txns/no_writes_to_config_transactions_with_prepared_transaction.js b/jstests/core/txns/no_writes_to_config_transactions_with_prepared_transaction.js
      index 067bf1482f..215f4c661b 100644
      --- a/jstests/core/txns/no_writes_to_config_transactions_with_prepared_transaction.js
      +++ b/jstests/core/txns/no_writes_to_config_transactions_with_prepared_transaction.js
      @@ -52,9 +52,9 @@ const txnNum = transactionEntry.txnNum;
       jsTestLog("Test that updates to config.transactions fails when there is a prepared " +
                 "transaction on the session");
       assert.commandFailedWithCode(
      -    sessionConfigDB.transactions.update({_id: transactionEntry._id},
      +    config.transactions.update({_id: transactionEntry._id},
                                               {$set: {"txnNumber": NumberLong(23)}}),
      -    40528);
      +    267);
       
       // Make sure that the txnNumber wasn't modified.
       transactionEntry = config.transactions.findOne();
      @@ -62,8 +62,8 @@ assert.eq(transactionEntry.txnNum, NumberLong(txnNum));
       
       jsTestLog("Test that deletes to config.transactions fails when there is a prepared " +
                 "transaction on the session");
      -assert.commandFailedWithCode(sessionConfigDB.transactions.remove({_id: transactionEntry._id}),
      -                             40528);
      +assert.commandFailedWithCode(config.transactions.remove({_id: transactionEntry._id}),
      +                             267);
       
       // Make sure that the entry in config.transactions wasn't removed.
       transactionEntry = config.transactions.findOne();
      @@ -72,9 +72,9 @@ assert(transactionEntry);
       jsTestLog("Test that dropping config.transactions fails when there is a prepared transaction" +
                 " on the session");
       assert.commandFailedWithCode(assert.throws(function() {
      -                                              sessionConfigDB.transactions.drop();
      +                                              config.transactions.drop();
                                                 }),
      -                                          40528);
      +                                          267);
       
       jsTestLog("Test that we can prepare a transaction on a different session");
       const session2 = db.getMongo().startSession({causalConsistency: false});
      
      Show
      Update no_writes_to_config_transactions_with_prepared_transaction.js with the following diff, so that writes to config.transactions are performed without a session. The update and delete fail correctly, but the drop does not fail as expected. diff --git a/jstests/core/txns/no_writes_to_config_transactions_with_prepared_transaction.js b/jstests/core/txns/no_writes_to_config_transactions_with_prepared_transaction.js index 067bf1482f..215f4c661b 100644 --- a/jstests/core/txns/no_writes_to_config_transactions_with_prepared_transaction.js +++ b/jstests/core/txns/no_writes_to_config_transactions_with_prepared_transaction.js @@ -52,9 +52,9 @@ const txnNum = transactionEntry.txnNum; jsTestLog( "Test that updates to config.transactions fails when there is a prepared " + "transaction on the session" ); assert .commandFailedWithCode( - sessionConfigDB.transactions.update({_id: transactionEntry._id}, + config.transactions.update({_id: transactionEntry._id}, {$set: { "txnNumber" : NumberLong(23)}}), - 40528); + 267); // Make sure that the txnNumber wasn't modified. transactionEntry = config.transactions.findOne(); @@ -62,8 +62,8 @@ assert .eq(transactionEntry.txnNum, NumberLong(txnNum)); jsTestLog( "Test that deletes to config.transactions fails when there is a prepared " + "transaction on the session" ); - assert .commandFailedWithCode(sessionConfigDB.transactions.remove({_id: transactionEntry._id}), - 40528); + assert .commandFailedWithCode(config.transactions.remove({_id: transactionEntry._id}), + 267); // Make sure that the entry in config.transactions wasn't removed. transactionEntry = config.transactions.findOne(); @@ -72,9 +72,9 @@ assert (transactionEntry); jsTestLog( "Test that dropping config.transactions fails when there is a prepared transaction" + " on the session" ); assert .commandFailedWithCode( assert . throws (function() { - sessionConfigDB.transactions.drop(); + config.transactions.drop(); }), - 40528); + 267); jsTestLog( "Test that we can prepare a transaction on a different session" ); const session2 = db.getMongo().startSession({causalConsistency: false });
    • Repl 2020-06-29, Repl 2020-07-13, Repl 2020-07-27
    • 23

          Assignee:
          vesselina.ratcheva@mongodb.com Vesselina Ratcheva (Inactive)
          Reporter:
          tess.avitabile@mongodb.com Tess Avitabile (Inactive)
          Votes:
          0 Vote for this issue
          Watchers:
          6 Start watching this issue

            Created:
            Updated:
            Resolved: