summaryrefslogtreecommitdiff
path: root/jstests/sharding/migration_coordinator_shutdown_in_critical_section.js
diff options
context:
space:
mode:
authorEsha Maharishi <esha.maharishi@mongodb.com>2020-02-05 21:52:42 +0000
committerevergreen <evergreen@mongodb.com>2020-02-05 21:52:42 +0000
commit769ee6a62ad027541e70237ab1b9d013bd36e84c (patch)
treeb0dd46754aa18f7bceffbcba49791278fa53a5d1 /jstests/sharding/migration_coordinator_shutdown_in_critical_section.js
parent18966553fc7f9d350c3428ea1a23162aba2526ef (diff)
downloadmongo-769ee6a62ad027541e70237ab1b9d013bd36e84c.tar.gz
SERVER-45901 Make moveChunk robust to being killOp'd after commit has been sent to the config but before the node has found out the commit decision
Diffstat (limited to 'jstests/sharding/migration_coordinator_shutdown_in_critical_section.js')
-rw-r--r--jstests/sharding/migration_coordinator_shutdown_in_critical_section.js75
1 files changed, 75 insertions, 0 deletions
diff --git a/jstests/sharding/migration_coordinator_shutdown_in_critical_section.js b/jstests/sharding/migration_coordinator_shutdown_in_critical_section.js
new file mode 100644
index 00000000000..b83927da3c8
--- /dev/null
+++ b/jstests/sharding/migration_coordinator_shutdown_in_critical_section.js
@@ -0,0 +1,75 @@
+/**
+ * Shuts down the donor primary at two points in the critical section: while the node is executing
+ * _configsvrEnsureChunkVersionIsGreaterThan and while the node is forcing a filtering metadata
+ * refresh.
+ *
+ * Marked as multiversion_incompatible because the failpoints used in this test were introduced
+ * on v4.4 mongod.
+ * @tags: [multiversion_incompatible]
+ */
+
+(function() {
+'use strict';
+
+// This test shuts down a shard primary.
+TestData.skipCheckingUUIDsConsistentAcrossCluster = true;
+TestData.skipCheckingIndexesConsistentAcrossCluster = true;
+
+load('jstests/libs/parallel_shell_helpers.js');
+
+function getNewNs(dbName) {
+ if (typeof getNewNs.counter == 'undefined') {
+ getNewNs.counter = 0;
+ }
+ getNewNs.counter++;
+ const collName = "ns" + getNewNs.counter;
+ return [collName, dbName + "." + collName];
+}
+
+const dbName = "test";
+
+function testShutDownAfterFailPoint(failPointName) {
+ let st = new ShardingTest({shards: 2});
+
+ const donorShard = st.shard0;
+ const recipientShard = st.shard1;
+
+ assert.commandWorked(st.s.adminCommand({enableSharding: dbName}));
+ assert.commandWorked(st.s.adminCommand({movePrimary: dbName, to: donorShard.shardName}));
+
+ const [collName, ns] = getNewNs(dbName);
+ jsTest.log("Testing with " + tojson(arguments) + " using ns " + ns);
+
+ assert.commandWorked(st.s.adminCommand({shardCollection: ns, key: {_id: 1}}));
+
+ // Insert some docs into the collection.
+ const numDocs = 1000;
+ var bulk = st.s.getDB(dbName).getCollection(collName).initializeUnorderedBulkOp();
+ for (var i = 0; i < numDocs; i++) {
+ bulk.insert({_id: i});
+ }
+ assert.commandWorked(bulk.execute());
+
+ // Simulate a network error on sending commit to the config server, so that the donor tries to
+ // recover the commit decision.
+ configureFailPoint(st.rs0.getPrimary(), "migrationCommitNetworkError");
+
+ // Set the requested failpoint and launch the moveChunk asynchronously.
+ let failPoint = configureFailPoint(st.rs0.getPrimary(), failPointName);
+ const awaitResult = startParallelShell(
+ funWithArgs(function(ns, toShardName) {
+ assert.commandWorked(db.adminCommand({moveChunk: ns, find: {_id: 0}, to: toShardName}));
+ }, ns, recipientShard.shardName), st.s.port);
+
+ jsTest.log("Waiting for moveChunk to reach " + failPointName + " failpoint");
+ failPoint.wait();
+
+ // Ensure we are able to shut down the donor primary by asserting that its exit code is 0.
+ assert.eq(0, MongoRunner.stopMongod(st.rs0.getPrimary(), null, {}, true /* waitpid */));
+
+ st.stop();
+}
+
+testShutDownAfterFailPoint("hangInEnsureChunkVersionIsGreaterThanThenThrow");
+testShutDownAfterFailPoint("hangInRefreshFilteringMetadataUntilSuccessThenThrow");
+})();