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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/**
* Test that the resharding operation is aborted if any of the recipient shards encounters
* an error during the Applying phase
*/
(function() {
"use strict";
load("jstests/libs/discover_topology.js");
load("jstests/sharding/libs/resharding_test_fixture.js");
const reshardingTest = new ReshardingTest({numDonors: 2, numRecipients: 1});
reshardingTest.setup();
const donorShardNames = reshardingTest.donorShardNames;
const sourceCollection = reshardingTest.createShardedCollection({
ns: "reshardingDb.coll",
shardKeyPattern: {oldKey: 1},
chunks: [
{min: {oldKey: MinKey}, max: {oldKey: 0}, shard: donorShardNames[0]},
{min: {oldKey: 0}, max: {oldKey: MaxKey}, shard: donorShardNames[1]},
],
});
const mongos = sourceCollection.getMongo();
const topology = DiscoverTopology.findConnectedNodes(mongos);
const donor0 = new Mongo(topology.shards[donorShardNames[0]].primary);
const recipientShardNames = reshardingTest.recipientShardNames;
const recipient = new Mongo(topology.shards[recipientShardNames[0]].primary);
// We have the recipient shard fail the _shardsvrReshardingOperationTime command to verify the
// ReshardingCoordinator can successfully abort the resharding operation even when the commit
// monitor doesn't see the recipient shard as being caught up enough to engage the critical section
// on the donor shards.
const shardsvrReshardingOperationTimeFailpoint = configureFailPoint(recipient, "failCommand", {
failInternalCommands: true,
errorCode: ErrorCodes.Interrupted,
failCommands: ["_shardsvrReshardingOperationTime"],
});
reshardingTest.withReshardingInBackground(
{
newShardKeyPattern: {newKey: 1},
newChunks: [{min: {newKey: MinKey}, max: {newKey: MaxKey}, shard: recipientShardNames[0]}],
},
() => {
// We wait until cloneTimestamp has been chosen to guarantee that any subsequent writes will
// be applied by the ReshardingOplogApplier.
reshardingTest.awaitCloneTimestampChosen();
// We connect directly to one of the donor shards to perform an operations which will later
// cause the recipient shard to error during its resharding oplog application. Connecting
// directly to the shard bypasses any synchronization which might otherwise occur from the
// Sharding DDL Coordinator.
const donor0Collection = donor0.getCollection(sourceCollection.getFullName());
assert.commandWorked(donor0Collection.runCommand("collMod"));
},
{
expectedErrorCode: ErrorCodes.OplogOperationUnsupported,
});
shardsvrReshardingOperationTimeFailpoint.off();
reshardingTest.teardown();
})();
|