blob: c24e13fa8317afc8fb40b6b600ed81183fef1dfb (
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
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/**
* Tests that replica set shard secondaries don't attempt to create primary-only service Instances
* or insert state documents for resharding.
*
* @tags: [
* uses_atclustertime,
* disabled_due_to_server_58295
* ]
*/
(function() {
"use strict";
load("jstests/libs/discover_topology.js");
load("jstests/libs/fail_point_util.js");
load("jstests/sharding/libs/resharding_test_fixture.js");
const reshardingTest = new ReshardingTest();
reshardingTest.setup();
const donorShardNames = reshardingTest.donorShardNames;
const sourceCollection = reshardingTest.createShardedCollection({
ns: "reshardingDb.coll",
shardKeyPattern: {oldKey: 1},
chunks: [{min: {oldKey: MinKey}, max: {oldKey: MaxKey}, shard: donorShardNames[0]}],
});
function triggerShardVersionRefreshOnSecondary(collection) {
// The shard version refresh would have failed and prevented the secondary from being read from
// if it had attempted to create a primary-only service Instance or insert a state document for
// resharding.
assert.commandWorked(mongos.adminCommand({flushRouterConfig: collection.getFullName()}));
collection.find().readPref("secondary").readConcern("local").itcount();
}
const mongos = sourceCollection.getMongo();
const topology = DiscoverTopology.findConnectedNodes(mongos);
const configPrimary = new Mongo(topology.configsvr.primary);
const fp = configureFailPoint(configPrimary, "reshardingPauseCoordinatorBeforeCloning");
const recipientShardNames = reshardingTest.recipientShardNames;
reshardingTest.withReshardingInBackground( //
{
newShardKeyPattern: {newKey: 1},
newChunks: [{min: {newKey: MinKey}, max: {newKey: MaxKey}, shard: recipientShardNames[0]}],
},
(tempNs) => {
fp.wait();
triggerShardVersionRefreshOnSecondary(sourceCollection);
const tempColl = mongos.getCollection(tempNs);
triggerShardVersionRefreshOnSecondary(tempColl);
fp.off();
});
reshardingTest.teardown();
})();
|