summaryrefslogtreecommitdiff
path: root/jstests/sharding/resharding_interrupt_before_create_state_machine.js
blob: 8b18d498ff21c980c22aa01f359f24e9aa7008df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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();
})();