From fffcdd7eba68147c7f0cdfd5fccbccb72e440bea Mon Sep 17 00:00:00 2001 From: Pavi Vetriselvan Date: Thu, 20 May 2021 18:34:00 -0400 Subject: [PATCH] SERVER-57089 Add skip_dbhash flag to ContinuousTenantMigration --- ...ration_kill_primary_jscore_passthrough.yml | 1 + ..._migration_stepdown_jscore_passthrough.yml | 1 + ...n_terminate_primary_jscore_passthrough.yml | 1 + .../testing/hooks/tenant_migration.py | 7 ++++- .../override_methods/inject_tenant_prefix.js | 26 ++++++++++--------- 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/buildscripts/resmokeconfig/suites/tenant_migration_kill_primary_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/tenant_migration_kill_primary_jscore_passthrough.yml index c0e183bfb32..aaabc652193 100644 --- a/buildscripts/resmokeconfig/suites/tenant_migration_kill_primary_jscore_passthrough.yml +++ b/buildscripts/resmokeconfig/suites/tenant_migration_kill_primary_jscore_passthrough.yml @@ -253,6 +253,7 @@ executor: readPreference: mode: "primary" retryWrites: true + skipTenantMigrationDBHash: false # We specify nodb so the shell used by each test will attempt to connect after loading the # retry logic in auto_retry_on_network_error.js. nodb: "" diff --git a/buildscripts/resmokeconfig/suites/tenant_migration_stepdown_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/tenant_migration_stepdown_jscore_passthrough.yml index 6d7d6381375..b6929676ec9 100644 --- a/buildscripts/resmokeconfig/suites/tenant_migration_stepdown_jscore_passthrough.yml +++ b/buildscripts/resmokeconfig/suites/tenant_migration_stepdown_jscore_passthrough.yml @@ -249,6 +249,7 @@ executor: readPreference: mode: "primary" retryWrites: true + skipTenantMigrationDBHash: false # We specify nodb so the shell used by each test will attempt to connect after loading the # retry logic in auto_retry_on_network_error.js. nodb: "" diff --git a/buildscripts/resmokeconfig/suites/tenant_migration_terminate_primary_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/tenant_migration_terminate_primary_jscore_passthrough.yml index 0403441f094..e5df514ae16 100644 --- a/buildscripts/resmokeconfig/suites/tenant_migration_terminate_primary_jscore_passthrough.yml +++ b/buildscripts/resmokeconfig/suites/tenant_migration_terminate_primary_jscore_passthrough.yml @@ -249,6 +249,7 @@ executor: readPreference: mode: "primary" retryWrites: true + skipTenantMigrationDBHash: false # We specify nodb so the shell used by each test will attempt to connect after loading the # retry logic in auto_retry_on_network_error.js. nodb: "" diff --git a/buildscripts/resmokelib/testing/hooks/tenant_migration.py b/buildscripts/resmokelib/testing/hooks/tenant_migration.py index e9e27ec6ae3..67aadba1123 100644 --- a/buildscripts/resmokelib/testing/hooks/tenant_migration.py +++ b/buildscripts/resmokelib/testing/hooks/tenant_migration.py @@ -242,6 +242,10 @@ class _TenantMigrationThread(threading.Thread): # pylint: disable=too-many-inst self._auth_options = shell_options["global_vars"]["TestData"]["authOptions"] self._test_report = test_report self._shell_options = shell_options + self._skip_dbhash = False + if "skipTenantMigrationDBHash" in self._shell_options["global_vars"]["TestData"]: + self._skip_dbhash = self._shell_options["global_vars"]["TestData"][ + "skipTenantMigrationDBHash"] self.__lifecycle = TenantMigrationLifeCycle() # Event set when the thread has been stopped using the 'stop()' method. @@ -411,7 +415,8 @@ class _TenantMigrationThread(threading.Thread): # pylint: disable=too-many-inst # in the next test. if is_committed: # Once we have committed a migration, run a dbhash check before rerouting commands. - self._check_tenant_migration_dbhash(migration_opts) + if not self._skip_dbhash: + self._check_tenant_migration_dbhash(migration_opts) # If the migration committed, to avoid routing commands incorrectly, wait for the # donor/proxy to reroute at least one command before doing garbage collection. Stop diff --git a/jstests/libs/override_methods/inject_tenant_prefix.js b/jstests/libs/override_methods/inject_tenant_prefix.js index 350b5d7dfa0..92031d24c91 100644 --- a/jstests/libs/override_methods/inject_tenant_prefix.js +++ b/jstests/libs/override_methods/inject_tenant_prefix.js @@ -516,19 +516,21 @@ Mongo.prototype.runCommandRetryOnTenantMigrationErrors = function( // After getting a TenantMigrationCommitted error, wait for the python test fixture // to do a dbhash check on the donor and recipient primaries before we retry the // command on the recipient. - assert.soon(() => { - let findRes = assert.commandWorked(originalRunCommand.apply(this, [ - "testTenantMigration", - { - find: "dbhashCheck", - filter: {_id: this.migrationStateDoc._id}, - }, - 0 - ])); + if (!TestData.skipTenantMigrationDBHash) { + assert.soon(() => { + let findRes = assert.commandWorked(originalRunCommand.apply(this, [ + "testTenantMigration", + { + find: "dbhashCheck", + filter: {_id: this.migrationStateDoc._id}, + }, + 0 + ])); - const docs = findRes.cursor.firstBatch; - return docs[0] != null; - }); + const docs = findRes.cursor.firstBatch; + return docs[0] != null; + }); + } } else if (migrationAbortedErr) { jsTestLog(`Got TenantMigrationAborted for command against database ${ dbNameWithTenantId} after trying ${numAttempts} times: ${tojson(resObj)}`);