diff options
10 files changed, 135 insertions, 128 deletions
diff --git a/buildscripts/resmokeconfig/suites/logical_session_cache_sharding_100ms_refresh_jscore_txns_passthrough.yml b/buildscripts/resmokeconfig/suites/logical_session_cache_sharding_100ms_refresh_jscore_txns_passthrough.yml index eb00d8877dd..a94e32ea179 100644 --- a/buildscripts/resmokeconfig/suites/logical_session_cache_sharding_100ms_refresh_jscore_txns_passthrough.yml +++ b/buildscripts/resmokeconfig/suites/logical_session_cache_sharding_100ms_refresh_jscore_txns_passthrough.yml @@ -8,9 +8,6 @@ selector: - jstests/core/txns/transactions_profiling.js - jstests/core/txns/transactions_profiling_with_drops.js - # No featureCompatibilityVersion parameter on mongos. - - jstests/core/txns/abort_unprepared_transactions_on_FCV_downgrade.js - # Implicitly creates a database through a collection rename, which does not work in a sharded # cluster. - jstests/core/txns/transactions_block_ddl.js diff --git a/buildscripts/resmokeconfig/suites/sharded_causally_consistent_jscore_txns_passthrough.yml b/buildscripts/resmokeconfig/suites/sharded_causally_consistent_jscore_txns_passthrough.yml index 4ed9f139ae1..d880673aabe 100644 --- a/buildscripts/resmokeconfig/suites/sharded_causally_consistent_jscore_txns_passthrough.yml +++ b/buildscripts/resmokeconfig/suites/sharded_causally_consistent_jscore_txns_passthrough.yml @@ -11,9 +11,6 @@ selector: - jstests/core/txns/transactions_profiling.js - jstests/core/txns/transactions_profiling_with_drops.js - # No featureCompatibilityVersion parameter on mongos. - - jstests/core/txns/abort_unprepared_transactions_on_FCV_downgrade.js - # Implicitly creates a database through a collection rename, which does not # work in a sharded cluster. - jstests/core/txns/transactions_block_ddl.js diff --git a/buildscripts/resmokeconfig/suites/sharded_collections_causally_consistent_jscore_txns_passthrough.yml b/buildscripts/resmokeconfig/suites/sharded_collections_causally_consistent_jscore_txns_passthrough.yml index 3c5fb1caf01..7a8af88b88a 100644 --- a/buildscripts/resmokeconfig/suites/sharded_collections_causally_consistent_jscore_txns_passthrough.yml +++ b/buildscripts/resmokeconfig/suites/sharded_collections_causally_consistent_jscore_txns_passthrough.yml @@ -7,9 +7,6 @@ selector: - jstests/core/txns/transactions_profiling.js - jstests/core/txns/transactions_profiling_with_drops.js - # No featureCompatibilityVersion parameter on mongos. - - jstests/core/txns/abort_unprepared_transactions_on_FCV_downgrade.js - # Implicitly creates a database through a collection rename, which does not work in a sharded # cluster. - jstests/core/txns/transactions_block_ddl.js diff --git a/buildscripts/resmokeconfig/suites/sharded_jscore_op_query_txns.yml b/buildscripts/resmokeconfig/suites/sharded_jscore_op_query_txns.yml index 14d7472119d..b108563f413 100644 --- a/buildscripts/resmokeconfig/suites/sharded_jscore_op_query_txns.yml +++ b/buildscripts/resmokeconfig/suites/sharded_jscore_op_query_txns.yml @@ -11,9 +11,6 @@ selector: - jstests/core/txns/transactions_profiling.js - jstests/core/txns/transactions_profiling_with_drops.js - # No featureCompatibilityVersion parameter on mongos. - - jstests/core/txns/abort_unprepared_transactions_on_FCV_downgrade.js - # Implicitly creates a database through a collection rename, which does not work in a sharded # cluster. - jstests/core/txns/transactions_block_ddl.js diff --git a/buildscripts/resmokeconfig/suites/sharded_jscore_txns.yml b/buildscripts/resmokeconfig/suites/sharded_jscore_txns.yml index 87ebb6eead4..18d0917fa92 100644 --- a/buildscripts/resmokeconfig/suites/sharded_jscore_txns.yml +++ b/buildscripts/resmokeconfig/suites/sharded_jscore_txns.yml @@ -11,9 +11,6 @@ selector: - jstests/core/txns/transactions_profiling.js - jstests/core/txns/transactions_profiling_with_drops.js - # No featureCompatibilityVersion parameter on mongos. - - jstests/core/txns/abort_unprepared_transactions_on_FCV_downgrade.js - # Implicitly creates a database through a collection rename, which does not work in a sharded # cluster. - jstests/core/txns/transactions_block_ddl.js diff --git a/buildscripts/resmokeconfig/suites/sharded_jscore_txns_sharded_collections.yml b/buildscripts/resmokeconfig/suites/sharded_jscore_txns_sharded_collections.yml index a12c05bfee7..447ec543b34 100644 --- a/buildscripts/resmokeconfig/suites/sharded_jscore_txns_sharded_collections.yml +++ b/buildscripts/resmokeconfig/suites/sharded_jscore_txns_sharded_collections.yml @@ -7,9 +7,6 @@ selector: - jstests/core/txns/transactions_profiling.js - jstests/core/txns/transactions_profiling_with_drops.js - # No featureCompatibilityVersion parameter on mongos. - - jstests/core/txns/abort_unprepared_transactions_on_FCV_downgrade.js - # Implicitly creates a database through a collection rename, which does not work in a sharded # cluster. - jstests/core/txns/transactions_block_ddl.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 deleted file mode 100644 index bee856d5e62..00000000000 --- a/jstests/core/txns/abort_unprepared_transactions_on_FCV_downgrade.js +++ /dev/null @@ -1,50 +0,0 @@ -/** - * 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, multiversion_incompatible] - */ -(function() { -"use strict"; - -const dbName = "test"; -const collName = "abort_unprepared_transactions_on_FCV_downgrade"; -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("Start a transaction."); - session.startTransaction({readConcern: {level: "snapshot"}}); - assert.commandWorked(sessionDB[collName].insert({_id: "insert-1"})); - - jsTestLog("Attempt to drop the collection. This should fail due to the open transaction."); - assert.commandFailedWithCode(testDB.runCommand({drop: collName, maxTimeMS: 1000}), - ErrorCodes.MaxTimeMSExpired); - - jsTestLog("Downgrade the featureCompatibilityVersion."); - assert.commandWorked(testDB.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV})); - checkFCV(adminDB, lastLTSFCV); - - jsTestLog("Drop the collection. This should succeed, since the transaction was aborted."); - assert.commandWorked(testDB.runCommand({drop: collName})); - - jsTestLog("Test that committing the transaction fails, since it was aborted."); - assert.commandFailedWithCode(session.commitTransaction_forTesting(), - ErrorCodes.NoSuchTransaction); -} finally { - jsTestLog("Restore the original featureCompatibilityVersion."); - assert.commandWorked(testDB.adminCommand({setFeatureCompatibilityVersion: latestFCV})); - checkFCV(adminDB, latestFCV); -} - -session.endSession(); -}()); diff --git a/jstests/core/txns/await_prepared_transactions_on_FCV_downgrade.js b/jstests/core/txns/await_prepared_transactions_on_FCV_downgrade.js deleted file mode 100644 index 4999ed1dfc8..00000000000 --- a/jstests/core/txns/await_prepared_transactions_on_FCV_downgrade.js +++ /dev/null @@ -1,60 +0,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, multiversion_incompatible] - */ -(function() { -"use strict"; -load("jstests/core/txns/libs/prepare_helpers.js"); - -const dbName = "test"; -const collName = "await_prepared_transactions_on_FCV_downgrade"; -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 session = testDB.getMongo().startSession(); -const sessionDB = session.getDatabase(dbName); - -try { - jsTestLog("Start a transaction."); - session.startTransaction(); - assert.commandWorked(sessionDB[collName].insert({"a": 1})); - - jsTestLog("Put that transaction into a prepared state."); - let prepareTimestamp = PrepareHelpers.prepareTransaction(session); - - // The setFCV command will need to acquire a global S lock to complete. The global - // lock is currently held by prepare, so that will block. We use a failpoint to make that - // command fail immediately when it tries to get the lock. - assert.commandWorked(testDB.adminCommand( - {configureFailPoint: "failNonIntentLocksIfWaitNeeded", mode: "alwaysOn"})); - - jsTestLog("Attempt to downgrade the featureCompatibilityVersion."); - assert.commandFailedWithCode(testDB.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV}), - ErrorCodes.LockTimeout); - - assert.commandWorked( - testDB.adminCommand({configureFailPoint: "failNonIntentLocksIfWaitNeeded", mode: "off"})); - - jsTestLog("Commit the prepared transaction."); - assert.commandWorked(PrepareHelpers.commitTransaction(session, prepareTimestamp)); - - jsTestLog("Rerun the setFCV command and let it complete successfully."); - assert.commandWorked(testDB.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV})); - checkFCV(adminDB, lastLTSFCV); - -} finally { - assert.commandWorked( - testDB.adminCommand({configureFailPoint: "failNonIntentLocksIfWaitNeeded", mode: "off"})); - - jsTestLog("Restore the original featureCompatibilityVersion."); - assert.commandWorked(testDB.adminCommand({setFeatureCompatibilityVersion: latestFCV})); - checkFCV(adminDB, latestFCV); -} - -session.endSession(); -}()); diff --git a/jstests/multiVersion/genericSetFCVUsage/abort_unprepared_transactions_on_FCV_downgrade.js b/jstests/multiVersion/genericSetFCVUsage/abort_unprepared_transactions_on_FCV_downgrade.js new file mode 100644 index 00000000000..603caeac826 --- /dev/null +++ b/jstests/multiVersion/genericSetFCVUsage/abort_unprepared_transactions_on_FCV_downgrade.js @@ -0,0 +1,61 @@ +/** + * 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, multiversion_incompatible] + */ +(function() { +"use strict"; + +function runTest(downgradeFCV) { + const rst = new ReplSetTest({nodes: [{binVersion: "latest"}]}); + rst.startSet(); + rst.initiate(); + const primary = rst.getPrimary(); + + const dbName = "test"; + const collName = "abort_unprepared_transactions_on_FCV_downgrade"; + const testDB = primary.getDB(dbName); + const adminDB = primary.getDB("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("Start a transaction."); + session.startTransaction({readConcern: {level: "snapshot"}}); + assert.commandWorked(sessionDB[collName].insert({_id: "insert-1"})); + + jsTestLog("Attempt to drop the collection. This should fail due to the open transaction."); + assert.commandFailedWithCode(testDB.runCommand({drop: collName, maxTimeMS: 1000}), + ErrorCodes.MaxTimeMSExpired); + + jsTestLog("Downgrade the featureCompatibilityVersion."); + assert.commandWorked(testDB.adminCommand({setFeatureCompatibilityVersion: downgradeFCV})); + checkFCV(adminDB, downgradeFCV); + + jsTestLog("Drop the collection. This should succeed, since the transaction was aborted."); + assert.commandWorked(testDB.runCommand({drop: collName})); + + jsTestLog("Test that committing the transaction fails, since it was aborted."); + assert.commandFailedWithCode(session.commitTransaction_forTesting(), + ErrorCodes.NoSuchTransaction); + } finally { + jsTestLog("Restore the original featureCompatibilityVersion."); + assert.commandWorked(testDB.adminCommand({setFeatureCompatibilityVersion: latestFCV})); + checkFCV(adminDB, latestFCV); + } + + session.endSession(); + rst.stopSet(); +} + +runTest(lastLTSFCV); +if (lastLTSFCV !== lastContinuousFCV) { + runTest(lastContinuousFCV); +} +}()); diff --git a/jstests/multiVersion/genericSetFCVUsage/await_prepared_transactions_on_FCV_downgrade.js b/jstests/multiVersion/genericSetFCVUsage/await_prepared_transactions_on_FCV_downgrade.js new file mode 100644 index 00000000000..62885735eb1 --- /dev/null +++ b/jstests/multiVersion/genericSetFCVUsage/await_prepared_transactions_on_FCV_downgrade.js @@ -0,0 +1,74 @@ +/** + * 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, multiversion_incompatible] + */ +(function() { +"use strict"; +load("jstests/core/txns/libs/prepare_helpers.js"); + +function runTest(downgradeFCV) { + const rst = new ReplSetTest({nodes: [{binVersion: "latest"}]}); + rst.startSet(); + rst.initiate(); + const primary = rst.getPrimary(); + + const dbName = "test"; + const collName = "await_prepared_transactions_on_FCV_downgrade"; + const testDB = primary.getDB(dbName); + const adminDB = primary.getDB("admin"); + + testDB[collName].drop({writeConcern: {w: "majority"}}); + assert.commandWorked(testDB.runCommand({create: collName, writeConcern: {w: "majority"}})); + + const session = testDB.getMongo().startSession(); + const sessionDB = session.getDatabase(dbName); + + try { + jsTestLog("Start a transaction."); + session.startTransaction(); + assert.commandWorked(sessionDB[collName].insert({"a": 1})); + + jsTestLog("Put that transaction into a prepared state."); + let prepareTimestamp = PrepareHelpers.prepareTransaction(session); + + // The setFCV command will need to acquire a global S lock to complete. The global + // lock is currently held by prepare, so that will block. We use a failpoint to make that + // command fail immediately when it tries to get the lock. + assert.commandWorked(testDB.adminCommand( + {configureFailPoint: "failNonIntentLocksIfWaitNeeded", mode: "alwaysOn"})); + + jsTestLog("Attempt to downgrade the featureCompatibilityVersion."); + assert.commandFailedWithCode( + testDB.adminCommand({setFeatureCompatibilityVersion: downgradeFCV}), + ErrorCodes.LockTimeout); + + assert.commandWorked(testDB.adminCommand( + {configureFailPoint: "failNonIntentLocksIfWaitNeeded", mode: "off"})); + + jsTestLog("Commit the prepared transaction."); + assert.commandWorked(PrepareHelpers.commitTransaction(session, prepareTimestamp)); + + jsTestLog("Rerun the setFCV command and let it complete successfully."); + assert.commandWorked(testDB.adminCommand({setFeatureCompatibilityVersion: downgradeFCV})); + checkFCV(adminDB, downgradeFCV); + + } finally { + assert.commandWorked(testDB.adminCommand( + {configureFailPoint: "failNonIntentLocksIfWaitNeeded", mode: "off"})); + + jsTestLog("Restore the original featureCompatibilityVersion."); + assert.commandWorked(testDB.adminCommand({setFeatureCompatibilityVersion: latestFCV})); + checkFCV(adminDB, latestFCV); + } + + session.endSession(); + rst.stopSet(); +} + +runTest(lastLTSFCV); +if (lastLTSFCV !== lastContinuousFCV) { + runTest(lastContinuousFCV); +} +}()); |