mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
SERVER-42481 Remove FCV checks around prepared transactions
This commit is contained in:
parent
2f815dbeb3
commit
710ccfe722
@ -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");
|
||||
|
@ -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"}));
|
||||
|
@ -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();
|
||||
}());
|
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user