diff options
author | Didier Nadeau <didier.nadeau@mongodb.com> | 2022-10-14 14:25:36 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-10-14 14:59:55 +0000 |
commit | 05518f9b480f4f65fc963b47ef4cf45c9e4807b5 (patch) | |
tree | 045107b3332febee3f8433f62ffa0993b3e13b0b | |
parent | a81af278bf063f677c6b23ae4c50c537edf7b07a (diff) | |
download | mongo-05518f9b480f4f65fc963b47ef4cf45c9e4807b5.tar.gz |
SERVER-68597 Skip temporary collection hashes at the end of shard split passthroughs
15 files changed, 80 insertions, 27 deletions
diff --git a/buildscripts/resmokeconfig/suites/shard_split_causally_consistent_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/shard_split_causally_consistent_jscore_passthrough.yml index 3e11ca7a45c..5a4556d557b 100644 --- a/buildscripts/resmokeconfig/suites/shard_split_causally_consistent_jscore_passthrough.yml +++ b/buildscripts/resmokeconfig/suites/shard_split_causally_consistent_jscore_passthrough.yml @@ -132,6 +132,9 @@ executor: keyFile: *keyFile keyFileData: *keyFileData roleGraphInvalidationIsFatal: true + # Temp collections are removed when the recipient steps up. We expect a mismatch, this + # ensures we don't compare them. + skipTempCollections: true hooks: - class: ContinuousShardSplit shell_options: diff --git a/buildscripts/resmokeconfig/suites/shard_split_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/shard_split_jscore_passthrough.yml index 99a59a0c000..4390b729779 100644 --- a/buildscripts/resmokeconfig/suites/shard_split_jscore_passthrough.yml +++ b/buildscripts/resmokeconfig/suites/shard_split_jscore_passthrough.yml @@ -66,6 +66,10 @@ executor: keyFile: *keyFile keyFileData: *keyFileData roleGraphInvalidationIsFatal: true + # Temp collections are removed when the recipient steps up. We expect a mismatch, this + # ensures we don't compare them. + skipTempCollections: true + hooks: # Hooks are set up in the order listed here, and torn down in the same order (not as a stack). # The ContinuousShardSplit hook must come before CleanEveryN so that the ShardSplitFixture's list diff --git a/buildscripts/resmokeconfig/suites/shard_split_kill_primary_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/shard_split_kill_primary_jscore_passthrough.yml index 9b241666129..9cf6b5b61fd 100644 --- a/buildscripts/resmokeconfig/suites/shard_split_kill_primary_jscore_passthrough.yml +++ b/buildscripts/resmokeconfig/suites/shard_split_kill_primary_jscore_passthrough.yml @@ -146,6 +146,9 @@ executor: global_vars: TestData: &TestData tenantIds: ["tenantA", "tenantB"] + # Temp collections are removed when the recipient steps up. We expect a mismatch, this + # ensures we don't compare them. + skipTempCollections: true auth: true authMechanism: SCRAM-SHA-256 keyFile: *keyFile diff --git a/buildscripts/resmokeconfig/suites/shard_split_multi_stmt_txn_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/shard_split_multi_stmt_txn_jscore_passthrough.yml index 3e2a1d842da..9dd31887588 100644 --- a/buildscripts/resmokeconfig/suites/shard_split_multi_stmt_txn_jscore_passthrough.yml +++ b/buildscripts/resmokeconfig/suites/shard_split_multi_stmt_txn_jscore_passthrough.yml @@ -268,6 +268,9 @@ executor: global_vars: TestData: &TestData tenantIds: ["tenantA", "tenantB"] + # Temp collections are removed when the recipient steps up. We expect a mismatch, this + # ensures we don't compare them. + skipTempCollections: true auth: true authMechanism: SCRAM-SHA-256 keyFile: *keyFile diff --git a/buildscripts/resmokeconfig/suites/shard_split_stepdown_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/shard_split_stepdown_jscore_passthrough.yml index a31b6d299c6..bed61445920 100644 --- a/buildscripts/resmokeconfig/suites/shard_split_stepdown_jscore_passthrough.yml +++ b/buildscripts/resmokeconfig/suites/shard_split_stepdown_jscore_passthrough.yml @@ -136,6 +136,9 @@ executor: global_vars: TestData: &TestData tenantIds: ["tenantA", "tenantB"] + # Temp collections are removed when the recipient steps up. We expect a mismatch, this + # ensures we don't compare them. + skipTempCollections: true auth: true authMechanism: SCRAM-SHA-256 keyFile: *keyFile diff --git a/buildscripts/resmokeconfig/suites/shard_split_terminate_primary_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/shard_split_terminate_primary_jscore_passthrough.yml index f9a76f8591c..50d325462ff 100644 --- a/buildscripts/resmokeconfig/suites/shard_split_terminate_primary_jscore_passthrough.yml +++ b/buildscripts/resmokeconfig/suites/shard_split_terminate_primary_jscore_passthrough.yml @@ -136,6 +136,9 @@ executor: global_vars: TestData: &TestData tenantIds: ["tenantA", "tenantB"] + # Temp collections are removed when the recipient steps up. We expect a mismatch, this + # ensures we don't compare them. + skipTempCollections: true auth: true authMechanism: SCRAM-SHA-256 keyFile: *keyFile diff --git a/jstests/hooks/run_check_tenant_migration_dbhash.js b/jstests/hooks/run_check_tenant_migration_dbhash.js index b34e975c015..933c9e6679f 100644 --- a/jstests/hooks/run_check_tenant_migration_dbhash.js +++ b/jstests/hooks/run_check_tenant_migration_dbhash.js @@ -39,12 +39,16 @@ while (true) { } } +const skipTempCollections = TestData.skipTempCollections ? true : false; + // We assume every db is under the tenant being migrated. if (TestData.tenantIds) { - TestData.tenantIds.forEach(tenantId => TenantMigrationUtil.checkTenantDBHashes( - donorRst, recipientRst, tenantId, excludedDBs)); + TestData.tenantIds.forEach( + tenantId => TenantMigrationUtil.checkTenantDBHashes( + {donorRst, recipientRst, tenantId, excludedDBs, skipTempCollections})); } else { - TenantMigrationUtil.checkTenantDBHashes(donorRst, recipientRst, tenantId, excludedDBs); + TenantMigrationUtil.checkTenantDBHashes( + {donorRst, recipientRst, tenantId, excludedDBs, skipTempCollections}); } // Mark that we have completed the dbhash check. diff --git a/jstests/replsets/libs/tenant_migration_test.js b/jstests/replsets/libs/tenant_migration_test.js index bd79c51b6bb..4bd4cb33994 100644 --- a/jstests/replsets/libs/tenant_migration_test.js +++ b/jstests/replsets/libs/tenant_migration_test.js @@ -266,7 +266,7 @@ function TenantMigrationTest({ // between the donor and recipient. if (stateRes.state === TenantMigrationTest.State.kCommitted) { TenantMigrationUtil.checkTenantDBHashes( - this.getDonorRst(), this.getRecipientRst(), tenantId); + {donorRst: this.getDonorRst(), recipientRst: this.getRecipientRst(), tenantId}); } return stateRes; diff --git a/jstests/replsets/libs/tenant_migration_util.js b/jstests/replsets/libs/tenant_migration_util.js index c6458fcc140..d6cd9f8bf70 100644 --- a/jstests/replsets/libs/tenant_migration_util.js +++ b/jstests/replsets/libs/tenant_migration_util.js @@ -352,12 +352,15 @@ var TenantMigrationUtil = (function() { * Compares the hashes for DBs that belong to the specified tenant between the donor and * recipient primaries. */ - function checkTenantDBHashes(donorRst, - recipientRst, - tenantId, - excludedDBs = [], - msgPrefix = 'checkTenantDBHashes', - ignoreUUIDs = false) { + function checkTenantDBHashes({ + donorRst, + recipientRst, + tenantId, + excludedDBs = [], + msgPrefix = 'checkTenantDBHashes', + ignoreUUIDs = false, + skipTempCollections = false + }) { // Always skip db hash checks for the config, admin, and local database. excludedDBs = [...excludedDBs, "config", "admin", "local"]; @@ -394,10 +397,10 @@ var TenantMigrationUtil = (function() { for (const dbName of combinedDBNames) { // Pass in an empty array for the secondaries, since we only wish to compare // the DB hashes between the donor and recipient primary in this test. - const donorDBHash = - assert.commandWorked(donorRst.getHashes(dbName, []).primary); - const recipientDBHash = - assert.commandWorked(recipientRst.getHashes(dbName, []).primary); + const donorDBHash = assert.commandWorked( + donorRst.getHashes(dbName, [], skipTempCollections).primary); + const recipientDBHash = assert.commandWorked( + recipientRst.getHashes(dbName, [], skipTempCollections).primary); const donorCollections = Object.keys(donorDBHash.collections); const donorCollInfos = new CollInfos(donorPrimaryConn, 'donorPrimary', dbName); diff --git a/jstests/replsets/tenant_migration_resume_collection_cloner_after_recipient_failover.js b/jstests/replsets/tenant_migration_resume_collection_cloner_after_recipient_failover.js index 02ccfc68c56..13eef15e0a9 100644 --- a/jstests/replsets/tenant_migration_resume_collection_cloner_after_recipient_failover.js +++ b/jstests/replsets/tenant_migration_resume_collection_cloner_after_recipient_failover.js @@ -101,8 +101,11 @@ const tenantMigrationFailoverTest = function(isTimeSeries, createCollFn, docs) { recipientColl = newRecipientPrimary.getDB(dbName).getCollection(collName); assert.eq(docs.length, recipientColl.find().itcount()); assert.docEq(recipientColl.find().sort({_id: 1}).toArray(), docs); - TenantMigrationUtil.checkTenantDBHashes( - tenantMigrationTest.getDonorRst(), tenantMigrationTest.getRecipientRst(), tenantId); + TenantMigrationUtil.checkTenantDBHashes({ + donorRst: tenantMigrationTest.getDonorRst(), + recipientRst: tenantMigrationTest.getRecipientRst(), + tenantId + }); tenantMigrationTest.stop(); recipientRst.stopSet(); diff --git a/jstests/replsets/tenant_migration_resume_collection_cloner_after_rename.js b/jstests/replsets/tenant_migration_resume_collection_cloner_after_rename.js index 2a6cd105502..d97e6986a1a 100644 --- a/jstests/replsets/tenant_migration_resume_collection_cloner_after_rename.js +++ b/jstests/replsets/tenant_migration_resume_collection_cloner_after_rename.js @@ -111,8 +111,11 @@ TenantMigrationTest.assertCommitted(migrationThread.returnData()); recipientColl = newRecipientPrimary.getDB(dbName).getCollection(collNameRenamed); assert.eq(4, recipientColl.find().itcount()); assert.eq(recipientColl.find().sort({_id: 1}).toArray(), docs); -TenantMigrationUtil.checkTenantDBHashes( - tenantMigrationTest.getDonorRst(), tenantMigrationTest.getRecipientRst(), tenantId); +TenantMigrationUtil.checkTenantDBHashes({ + donorRst: tenantMigrationTest.getDonorRst(), + recipientRst: tenantMigrationTest.getRecipientRst(), + tenantId +}); tenantMigrationTest.stop(); recipientRst.stopSet(); diff --git a/jstests/replsets/tenant_migration_resume_oplog_application.js b/jstests/replsets/tenant_migration_resume_oplog_application.js index ef231f60e65..9d6661753ab 100644 --- a/jstests/replsets/tenant_migration_resume_oplog_application.js +++ b/jstests/replsets/tenant_migration_resume_oplog_application.js @@ -107,8 +107,11 @@ resultsArr = appliedNoOps.toArray(); assert.eq(3, appliedNoOps.count(), appliedNoOps); assert.eq(docsToApply[2], resultsArr[2].o2.o, resultsArr); -TenantMigrationUtil.checkTenantDBHashes( - tenantMigrationTest.getDonorRst(), tenantMigrationTest.getRecipientRst(), tenantId); +TenantMigrationUtil.checkTenantDBHashes({ + donorRst: tenantMigrationTest.getDonorRst(), + recipientRst: tenantMigrationTest.getRecipientRst(), + tenantId +}); tenantMigrationTest.stop(); recipientRst.stopSet(); })(); diff --git a/jstests/replsets/tenant_migration_retry_session_migration.js b/jstests/replsets/tenant_migration_retry_session_migration.js index dcf98d09438..7d75a0d506a 100644 --- a/jstests/replsets/tenant_migration_retry_session_migration.js +++ b/jstests/replsets/tenant_migration_retry_session_migration.js @@ -156,8 +156,11 @@ assert.commandWorked(recipientPrimary.getDB(kDbName).runCommand({ // The dbhash between the donor and the recipient should still match after retrying // commitTransaction and the retryable writes because they should be noop. -TenantMigrationUtil.checkTenantDBHashes( - tenantMigrationTest.getDonorRst(), tenantMigrationTest.getRecipientRst(), kTenantId); +TenantMigrationUtil.checkTenantDBHashes({ + donorRst: tenantMigrationTest.getDonorRst(), + recipientRst: tenantMigrationTest.getRecipientRst(), + tenantId: kTenantId +}); tenantMigrationTest.stop(); })(); diff --git a/src/mongo/db/commands/dbhash.cpp b/src/mongo/db/commands/dbhash.cpp index 442c3fe728d..2eaadf286d2 100644 --- a/src/mongo/db/commands/dbhash.cpp +++ b/src/mongo/db/commands/dbhash.cpp @@ -61,6 +61,8 @@ namespace mongo { namespace { +constexpr char SKIP_TEMP_COLLECTION[] = "skipTempCollections"; + class DBHashCmd : public BasicCommand { public: DBHashCmd() : BasicCommand("dbHash", "dbhash") {} @@ -136,6 +138,12 @@ public: } } + const bool skipTempCollections = + cmdObj.hasField(SKIP_TEMP_COLLECTION) && cmdObj[SKIP_TEMP_COLLECTION].trueValue(); + if (skipTempCollections) { + LOGV2(6859700, "Skipping hash computation for temporary collections"); + } + // For empty databasename on first command field, the following code depends on the "." // on ns to find the invalid empty db name instead of checking empty db name directly. const std::string ns = parseNs(dbName, cmdObj).ns(); @@ -256,6 +264,10 @@ public: return true; } + if (skipTempCollections && collection->isTemporary()) { + return true; + } + if (desiredCollections.size() > 0 && desiredCollections.count(collNss.coll().toString()) == 0) return true; diff --git a/src/mongo/shell/replsettest.js b/src/mongo/shell/replsettest.js index edb4aacfa5b..c3ce7394822 100644 --- a/src/mongo/shell/replsettest.js +++ b/src/mongo/shell/replsettest.js @@ -2262,9 +2262,9 @@ var ReplSetTest = function(opts) { } }; - this.getHashesUsingSessions = function(sessions, dbName, { - readAtClusterTime, - } = {}) { + this.getHashesUsingSessions = function( + sessions, dbName, {readAtClusterTime, + skipTempCollections = false} = {skipTempCollections: false}) { return sessions.map(session => { const commandObj = {dbHash: 1}; const db = session.getDatabase(dbName); @@ -2277,6 +2277,9 @@ var ReplSetTest = function(opts) { commandObj.$_internalReadAtClusterTime = readAtClusterTime; } } + if (skipTempCollections) { + commandObj.skipTempCollections = 1; + } return assert.commandWorked(db.runCommand(commandObj)); }); @@ -2284,7 +2287,7 @@ var ReplSetTest = function(opts) { // Gets the dbhash for the current primary and for all secondaries (or the members of // 'secondaries', if specified). - this.getHashes = function(dbName, secondaries) { + this.getHashes = function(dbName, secondaries, skipTempCollections) { assert.neq(dbName, 'local', 'Cannot run getHashes() on the "local" database'); // _determineLiveSecondaries() repopulates both 'self._secondaries' and 'self._primary'. If @@ -2298,7 +2301,7 @@ var ReplSetTest = function(opts) { }) ].map(conn => conn.getDB('test').getSession()); - const hashes = this.getHashesUsingSessions(sessions, dbName); + const hashes = this.getHashesUsingSessions(sessions, dbName, {skipTempCollections}); return {primary: hashes[0], secondaries: hashes.slice(1)}; }; |