summaryrefslogtreecommitdiff
path: root/jstests/hooks
diff options
context:
space:
mode:
authorJason Zhang <jason.zhang@mongodb.com>2021-05-24 15:25:29 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-06-04 18:00:45 +0000
commit3ebc15ca093bc83bd478914df4259adf4177c833 (patch)
tree7348492d50574a35599565a91d195309e7b2b4db /jstests/hooks
parent3cdb8bdb74ba1be8e778fdac9bfa04304d655a6e (diff)
downloadmongo-3ebc15ca093bc83bd478914df4259adf4177c833.tar.gz
SERVER-57090 Investigate tenant dbhash check behavior with concurrent failovers
Diffstat (limited to 'jstests/hooks')
-rw-r--r--jstests/hooks/run_check_tenant_migration_dbhash.js35
1 files changed, 27 insertions, 8 deletions
diff --git a/jstests/hooks/run_check_tenant_migration_dbhash.js b/jstests/hooks/run_check_tenant_migration_dbhash.js
index f826dfa12af..779ab9d1795 100644
--- a/jstests/hooks/run_check_tenant_migration_dbhash.js
+++ b/jstests/hooks/run_check_tenant_migration_dbhash.js
@@ -2,7 +2,7 @@
'use strict';
(function() {
-load('jstests/libs/discover_topology.js'); // For Topology and DiscoverTopology.
+
load("jstests/replsets/libs/tenant_migration_util.js");
const excludedDBs = ["testTenantMigration"];
@@ -10,17 +10,36 @@ const testDBName = "testTenantMigration";
const dbhashCollName = "dbhashCheck";
const tenantId = TestData.tenantId;
const migrationId = UUID(TestData.migrationIdString);
+const retryOnNetworkErrors = TestData.networkErrorAndTxnOverrideConfig &&
+ TestData.networkErrorAndTxnOverrideConfig.retryOnNetworkErrors;
-const donorRst = new ReplSetTest(TestData.donorConnectionString);
-const recipientRst = new ReplSetTest(TestData.recipientConnectionString);
+let donorRst;
+let recipientRst;
+let donorDB;
+while (true) {
+ try {
+ donorRst = new ReplSetTest(TestData.donorConnectionString);
+ recipientRst = new ReplSetTest(TestData.recipientConnectionString);
-const donorPrimary = donorRst.getPrimary();
-const donorPrimaryDB = donorPrimary.getDB(testDBName);
+ // In failover suites, we want to allow retryable writes in case there is a failover while
+ // running the tenant dbhash check. In non-failover suites we dont expect to see any
+ // failovers, but we run in a session to keep the code simple.
+ donorDB =
+ new Mongo(donorRst.getURL()).startSession({retryWrites: true}).getDatabase(testDBName);
+ break;
+ } catch (e) {
+ if (!TenantMigrationUtil.checkIfRetriableErrorForTenantDbHashCheck(e)) {
+ throw e;
+ }
+ print(`Got error: ${tojson(e)}. Retrying ReplSetTest setup on retriable error.`);
+ }
+}
// We assume every db is under the tenant being migrated.
-TenantMigrationUtil.checkTenantDBHashes(donorRst, recipientRst, tenantId, excludedDBs);
+TenantMigrationUtil.checkTenantDBHashes(
+ donorRst, recipientRst, tenantId, excludedDBs, retryOnNetworkErrors);
// Mark that we have completed the dbhash check.
-assert.commandWorked(
- donorPrimaryDB[dbhashCollName].insert([{_id: migrationId}], {writeConcern: {w: "majority"}}));
+assert.commandWorked(donorDB.runCommand(
+ {insert: dbhashCollName, documents: [{_id: migrationId}], writeConcern: {w: "majority"}}));
})();