diff options
author | Cheahuychou Mao <mao.cheahuychou@gmail.com> | 2022-05-22 23:50:35 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-05-23 16:35:29 +0000 |
commit | fb115177b008ca06797095504c26568d1a9a4cea (patch) | |
tree | 98b263e4a9bc2c5b6d1bedc9a886872a4edcb98f /jstests | |
parent | 76d6c3a7645d622d89f1316af69e7f11afe8cf46 (diff) | |
download | mongo-fb115177b008ca06797095504c26568d1a9a4cea.tar.gz |
SERVER-66647 internal_transactions_unsharded.js should set storeFindAndModifyImagesInSideCollection on all mongods
(cherry picked from commit 7a8e211d20de65c14f525acdef662eeea28d441c)
Diffstat (limited to 'jstests')
3 files changed, 32 insertions, 38 deletions
diff --git a/jstests/concurrency/fsm_workloads/internal_transactions_setFCV.js b/jstests/concurrency/fsm_workloads/internal_transactions_setFCV.js index 7a3a39d27d7..e145e9294ad 100644 --- a/jstests/concurrency/fsm_workloads/internal_transactions_setFCV.js +++ b/jstests/concurrency/fsm_workloads/internal_transactions_setFCV.js @@ -76,6 +76,8 @@ var $config = extendWorkload($config, function($config, $super) { }; $config.setup = function(db, collName, cluster) { + $super.setup.apply(this, arguments); + if (cluster.isSharded()) { // Set the transactionLifetimeLimitSeconds to 60 seconds so that cross-shard // transactions that start between when setFCV aborts unprepared transactions and when @@ -93,6 +95,8 @@ var $config = extendWorkload($config, function($config, $super) { const fcvValues = [lastLTSFCV, lastContinuousFCV, latestFCV]; $config.teardown = function(db, collName, cluster) { + $super.teardown.apply(this, arguments); + assert.commandWorked(db.adminCommand({setFeatureCompatibilityVersion: latestFCV})); if (cluster.isSharded()) { diff --git a/jstests/concurrency/fsm_workloads/internal_transactions_sharded.js b/jstests/concurrency/fsm_workloads/internal_transactions_sharded.js index ac0afe4b4bb..8aba3b3a10b 100644 --- a/jstests/concurrency/fsm_workloads/internal_transactions_sharded.js +++ b/jstests/concurrency/fsm_workloads/internal_transactions_sharded.js @@ -17,10 +17,6 @@ load('jstests/concurrency/fsm_workloads/internal_transactions_unsharded.js'); load('jstests/libs/fail_point_util.js'); var $config = extendWorkload($config, function($config, $super) { - // This workload sets the 'storeFindAndModifyImagesInSideCollection' parameter to a random bool - // during setup() and restores the original value during teardown(). - $config.data.originalStoreFindAndModifyImagesInSideCollection = {}; - $config.data.getQueryForDocument = function getQueryForDocument(doc) { // The query for a write command against a sharded collection must contain the shard key. const query = $super.data.getQueryForDocument.apply(this, arguments); @@ -109,24 +105,7 @@ var $config = extendWorkload($config, function($config, $super) { } } - const enableFindAndModifyImageCollection = this.generateRandomBool(); - cluster.executeOnMongodNodes((db) => { - const res = assert.commandWorked(db.adminCommand({ - setParameter: 1, - storeFindAndModifyImagesInSideCollection: enableFindAndModifyImageCollection - })); - this.originalStoreFindAndModifyImagesInSideCollection[db.getMongo().host] = res.was; - }); - }; - - $config.teardown = function teardown(db, collName, cluster) { - cluster.executeOnMongodNodes((db) => { - assert.commandWorked(db.adminCommand({ - setParameter: 1, - storeFindAndModifyImagesInSideCollection: - this.originalStoreFindAndModifyImagesInSideCollection[db.getMongo().host] - })); - }); + this.overrideStoreFindAndModifyImagesInSideCollection(cluster); }; return $config; diff --git a/jstests/concurrency/fsm_workloads/internal_transactions_unsharded.js b/jstests/concurrency/fsm_workloads/internal_transactions_unsharded.js index ea7a00b7b55..492f331837a 100644 --- a/jstests/concurrency/fsm_workloads/internal_transactions_unsharded.js +++ b/jstests/concurrency/fsm_workloads/internal_transactions_unsharded.js @@ -73,7 +73,7 @@ var $config = extendWorkload($config, function($config, $super) { // This workload sets the 'storeFindAndModifyImagesInSideCollection' parameter to a random bool // during setup() and restores the original value during teardown(). - $config.data.originalStoreFindAndModifyImagesInSideCollection = undefined; + $config.data.originalStoreFindAndModifyImagesInSideCollection = {}; // Determine if this workload needs to use causally consistent sessions. $config.data.shouldUseCausalConsistency = (() => { @@ -445,6 +445,30 @@ var $config = extendWorkload($config, function($config, $super) { assert.commandWorked(bulk.execute()); }; + $config.data.overrideStoreFindAndModifyImagesInSideCollection = + function overrideStoreFindAndModifyImagesInSideCollection(cluster) { + // Store the findAndModify images in the oplog half of the time. + const enableFindAndModifyImageCollection = this.generateRandomBool(); + cluster.executeOnMongodNodes((db) => { + const res = assert.commandWorked(db.adminCommand({ + setParameter: 1, + storeFindAndModifyImagesInSideCollection: enableFindAndModifyImageCollection + })); + this.originalStoreFindAndModifyImagesInSideCollection[db.getMongo().host] = res.was; + }); + }; + + $config.data.restoreStoreFindAndModifyImagesInSideCollection = + function restoreStoreFindAndModifyImagesInSideCollection(cluster) { + cluster.executeOnMongodNodes((db) => { + assert.commandWorked(db.adminCommand({ + setParameter: 1, + storeFindAndModifyImagesInSideCollection: + this.originalStoreFindAndModifyImagesInSideCollection[db.getMongo().host] + })); + }); + }; + $config.setup = function setup(db, collName, cluster) { assert.commandWorked(db.createCollection(collName, {writeConcern: {w: "majority"}})); if (this.insertInitialDocsOnSetUp) { @@ -454,24 +478,11 @@ var $config = extendWorkload($config, function($config, $super) { this.insertInitialDocuments(db, collName, tid); } } - - // Store the findAndModify images in the oplog half of the time. - const enableFindAndModifyImageCollection = this.generateRandomBool(); - this.originalStoreFindAndModifyImagesInSideCollection = - assert - .commandWorked(db.adminCommand({ - setParameter: 1, - storeFindAndModifyImagesInSideCollection: enableFindAndModifyImageCollection - })) - .was; + this.overrideStoreFindAndModifyImagesInSideCollection(cluster); }; $config.teardown = function teardown(db, collName, cluster) { - assert.commandWorked(db.adminCommand({ - setParameter: 1, - storeFindAndModifyImagesInSideCollection: - this.originalStoreFindAndModifyImagesInSideCollection - })); + this.restoreStoreFindAndModifyImagesInSideCollection(cluster); }; /** |