summaryrefslogtreecommitdiff
path: root/jstests/sharding/resharding_interrupt_before_create_state_machine.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/sharding/resharding_interrupt_before_create_state_machine.js')
-rw-r--r--jstests/sharding/resharding_interrupt_before_create_state_machine.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/jstests/sharding/resharding_interrupt_before_create_state_machine.js b/jstests/sharding/resharding_interrupt_before_create_state_machine.js
new file mode 100644
index 00000000000..8b18d498ff2
--- /dev/null
+++ b/jstests/sharding/resharding_interrupt_before_create_state_machine.js
@@ -0,0 +1,46 @@
+/**
+ * Test that reshardCollection does not hang if its opCtx is interrupted between inserting the state
+ * document for its state machine and starting that state machine. See SERVER-74647.
+ */
+(function() {
+"use strict";
+load("jstests/sharding/libs/resharding_test_fixture.js");
+load("jstests/libs/fail_point_util.js");
+load("jstests/libs/discover_topology.js");
+
+const sourceNs = "reshardingDb.coll";
+
+const reshardingTest = new ReshardingTest();
+reshardingTest.setup();
+
+const donorShardNames = reshardingTest.donorShardNames;
+const recipientShardNames = reshardingTest.recipientShardNames;
+
+const inputCollection = reshardingTest.createShardedCollection({
+ ns: sourceNs,
+ shardKeyPattern: {oldKey: 1},
+ chunks: [
+ {min: {oldKey: MinKey}, max: {oldKey: MaxKey}, shard: donorShardNames[0]},
+ ],
+});
+
+const mongos = inputCollection.getMongo();
+const topology = DiscoverTopology.findConnectedNodes(mongos);
+const donorPrimary = new Mongo(topology.shards[donorShardNames[0]].primary);
+
+const failpoint =
+ configureFailPoint(donorPrimary, "reshardingInterruptAfterInsertStateMachineDocument");
+
+reshardingTest.withReshardingInBackground({
+ newShardKeyPattern: {newKey: 1},
+ newChunks: [
+ {min: {newKey: MinKey}, max: {newKey: MaxKey}, shard: recipientShardNames[0]},
+ ]
+},
+ () => {
+ failpoint.wait();
+ failpoint.off();
+ });
+
+reshardingTest.teardown();
+})();