Files
mongo/jstests/sharding/resharding_large_number_of_initial_chunks.js
Brett Nawrocki 05ee839a82 SERVER-60945 Increase critical section timeout for resharding test
Resharding test fixture sets the value for resharding critical section
timeout server parameter to 24 hours.
resharding_large_number_of_initial_chunks.js does not use resharding
test fixture and so uses the default value of 5 seconds. This can cause
spurious failures during periods of time where the test hosts are being
particularly slow. Therefore, the timeout has been increased to 24
hours.
2021-10-26 17:07:41 +00:00

70 lines
2.0 KiB
JavaScript

/**
* Tests that resharding can complete successfully when the original collection has a large number
* of chunks.
*
* @tags: [
* uses_atclustertime,
* resource_intensive,
* exclude_from_large_txns
* ]
*/
(function() {
"use strict";
load("jstests/sharding/libs/find_chunks_util.js");
const st = new ShardingTest({
mongos: 1,
shards: 2,
config: 1,
other: {
configOptions: {
setParameter:
{reshardingCriticalSectionTimeoutMillis: 24 * 60 * 60 * 1000 /* 1 day */}
}
}
});
const kDbName = 'db';
const collName = 'foo';
const ns = kDbName + '.' + collName;
const mongos = st.s;
assert.commandWorked(mongos.adminCommand({enableSharding: kDbName}));
assert.commandWorked(mongos.adminCommand({shardCollection: ns, key: {oldKey: 1}}));
let nZones = 10000;
let zones = [];
let shard0Zones = [];
let shard1Zones = [];
for (let i = 0; i < nZones; i++) {
let zoneName = "zone" + i;
zones.push({zone: zoneName, min: {"newKey": i}, max: {"newKey": i + 1}});
if (i % 2 == 0) {
shard0Zones.push(zoneName);
} else {
shard1Zones.push(zoneName);
}
}
jsTestLog("Updating First Zone");
assert.commandWorked(
mongos.getDB("config").shards.update({_id: st.shard0.shardName}, {$set: {tags: shard0Zones}}));
jsTestLog("Updating First Zone");
assert.commandWorked(
mongos.getDB("config").shards.update({_id: st.shard1.shardName}, {$set: {tags: shard1Zones}}));
jsTestLog("Resharding Collection");
assert.commandWorked(mongos.adminCommand({reshardCollection: ns, key: {newKey: 1}, zones: zones}));
// Assert that the correct number of zones and chunks documents exist after resharding 'db.foo'.
// There should be two more chunks docs than zones docs created to cover the ranges
// {newKey: minKey -> newKey : 0} and {newKey: nZones -> newKey : maxKey} which are not associated
// with a zone.
assert.eq(mongos.getDB("config").tags.find({ns: ns}).itcount(), nZones);
assert.eq(findChunksUtil.countChunksForNs(mongos.getDB("config"), ns), nZones + 2);
st.stop();
})();