From 710ccfe722e6299b9288697967e04c50730b7eb6 Mon Sep 17 00:00:00 2001 From: Jason Chan Date: Thu, 1 Aug 2019 10:35:28 -0400 Subject: [PATCH] SERVER-42481 Remove FCV checks around prepared transactions --- ...nprepared_transactions_on_FCV_downgrade.js | 8 ++- ..._prepared_transactions_on_FCV_downgrade.js | 11 +--- jstests/core/txns/prepare_requires_fcv42.js | 59 ------------------- src/mongo/db/s/txn_two_phase_commit_cmds.cpp | 5 -- 4 files changed, 9 insertions(+), 74 deletions(-) delete mode 100644 jstests/core/txns/prepare_requires_fcv42.js diff --git a/jstests/core/txns/abort_unprepared_transactions_on_FCV_downgrade.js b/jstests/core/txns/abort_unprepared_transactions_on_FCV_downgrade.js index aadda6561a9..e17cdbc5631 100644 --- a/jstests/core/txns/abort_unprepared_transactions_on_FCV_downgrade.js +++ b/jstests/core/txns/abort_unprepared_transactions_on_FCV_downgrade.js @@ -1,5 +1,9 @@ -// Test that open unprepared transactions are aborted on FCV downgrade. -// @tags: [uses_transactions] +/** + * Test that open unprepared transactions are aborted on FCV downgrade. This test covers the + * behavior between FCV downgrade and unprepared transactions as of v4.2. It is safe to change this + * test's behavior or remove this test entirely if the behavior changes post v4.2. + * @tags: [uses_transactions] + */ (function() { "use strict"; load("jstests/libs/feature_compatibility_version.js"); diff --git a/jstests/core/txns/await_prepared_transactions_on_FCV_downgrade.js b/jstests/core/txns/await_prepared_transactions_on_FCV_downgrade.js index 32e5822519c..e07b612febc 100644 --- a/jstests/core/txns/await_prepared_transactions_on_FCV_downgrade.js +++ b/jstests/core/txns/await_prepared_transactions_on_FCV_downgrade.js @@ -1,5 +1,7 @@ /** - * Test that we wait for prepared transactions to finish during downgrade to FCV 4.0. + * Test that we wait for prepared transactions to finish during FCV downgrade. This test covers the + * locking behavior as of v4.2. It is safe to change this test's behavior or remove this test + * entirely if the locking behavior changes post v4.2. * @tags: [uses_transactions, uses_prepare_transaction] */ (function() { @@ -50,13 +52,6 @@ try { assert.commandWorked(testDB.adminCommand({setFeatureCompatibilityVersion: lastStableFCV})); checkFCV(adminDB, lastStableFCV); - jsTestLog("Verify that we are not allowed to prepare a transaction after downgrading."); - session.startTransaction(); - assert.commandWorked(sessionDB[collName].insert({"b": 2})); - assert.commandFailedWithCode(sessionDB.adminCommand({prepareTransaction: 1}), - ErrorCodes.CommandNotSupported); - assert.commandFailedWithCode(session.abortTransaction_forTesting(), - ErrorCodes.NoSuchTransaction); } finally { assert.commandWorked( testDB.adminCommand({configureFailPoint: "failNonIntentLocksIfWaitNeeded", mode: "off"})); diff --git a/jstests/core/txns/prepare_requires_fcv42.js b/jstests/core/txns/prepare_requires_fcv42.js deleted file mode 100644 index 6f32918d332..00000000000 --- a/jstests/core/txns/prepare_requires_fcv42.js +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Tests that 'prepareTransaction' only succeeds in FCV 4.2. - * - * @tags: [uses_transactions, uses_prepare_transaction] - */ -(function() { -"use strict"; -load("jstests/libs/feature_compatibility_version.js"); -load("jstests/core/txns/libs/prepare_helpers.js"); - -const dbName = "test"; -const collName = "prepare_requires_fcv42"; -const testDB = db.getSiblingDB(dbName); -const adminDB = db.getSiblingDB('admin'); - -testDB[collName].drop({writeConcern: {w: "majority"}}); -assert.commandWorked(testDB.runCommand({create: collName, writeConcern: {w: "majority"}})); - -const sessionOptions = { - causalConsistency: false -}; -const session = testDB.getMongo().startSession(sessionOptions); -const sessionDB = session.getDatabase(dbName); - -try { - jsTestLog("Transaction succeeds in latest FCV."); - checkFCV(adminDB, latestFCV); - session.startTransaction(); - assert.commandWorked(sessionDB[collName].insert({_id: "a"})); - let prepareTimestamp = PrepareHelpers.prepareTransaction(session); - assert.commandWorked(PrepareHelpers.commitTransaction(session, prepareTimestamp)); - - jsTestLog("Downgrade the featureCompatibilityVersion."); - assert.commandWorked(testDB.adminCommand({setFeatureCompatibilityVersion: lastStableFCV})); - checkFCV(adminDB, lastStableFCV); - - jsTestLog("Transaction fails to prepare in last stable FCV."); - session.startTransaction(); - assert.commandWorked(sessionDB[collName].insert({_id: "b"})); - assert.commandFailedWithCode(sessionDB.adminCommand({prepareTransaction: 1}), - ErrorCodes.CommandNotSupported); - // Abort the transaction in the shell. - assert.commandFailedWithCode(session.abortTransaction_forTesting(), - ErrorCodes.NoSuchTransaction); - -} finally { - jsTestLog("Restore the original featureCompatibilityVersion."); - assert.commandWorked(testDB.adminCommand({setFeatureCompatibilityVersion: latestFCV})); - checkFCV(adminDB, latestFCV); -} - -jsTestLog("Transaction succeeds in latest FCV after upgrade."); -session.startTransaction(); -assert.commandWorked(sessionDB[collName].insert({_id: "c"})); -let prepareTimestamp = PrepareHelpers.prepareTransaction(session); -assert.commandWorked(PrepareHelpers.commitTransaction(session, prepareTimestamp)); - -session.endSession(); -}()); diff --git a/src/mongo/db/s/txn_two_phase_commit_cmds.cpp b/src/mongo/db/s/txn_two_phase_commit_cmds.cpp index b48811ec994..0c0583003e2 100644 --- a/src/mongo/db/s/txn_two_phase_commit_cmds.cpp +++ b/src/mongo/db/s/txn_two_phase_commit_cmds.cpp @@ -103,11 +103,6 @@ public: << opCtx->getTxnNumber() << " on session " << opCtx->getLogicalSessionId()->toBSON(); - uassert(ErrorCodes::CommandNotSupported, - "'prepareTransaction' is only supported in feature compatibility version 4.2", - (serverGlobalParams.featureCompatibility.getVersion() == - ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42)); - uassert(ErrorCodes::NoSuchTransaction, "Transaction isn't in progress", txnParticipant.inMultiDocumentTransaction());