summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authornandinibhartiyaMDB <nandini.bhartiya@mongodb.com>2023-05-11 04:34:31 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-05-11 05:34:10 +0000
commitbbb51d48561a47e6dc6e6aec9abf3463c1b6acc3 (patch)
treefc90d9d9761f800f1646c672b350708de64df5ea /jstests
parent83e593092544b7bce255f3fc25e2d8b0758ea962 (diff)
downloadmongo-bbb51d48561a47e6dc6e6aec9abf3463c1b6acc3.tar.gz
SERVER-76790: Fix holding extra tickets during resharding oplog application
Diffstat (limited to 'jstests')
-rw-r--r--jstests/sharding/libs/resharding_test_fixture.js16
-rw-r--r--jstests/sharding/resharding_with_multi_deletes_reduced_ticket_pool_size.js50
2 files changed, 66 insertions, 0 deletions
diff --git a/jstests/sharding/libs/resharding_test_fixture.js b/jstests/sharding/libs/resharding_test_fixture.js
index e05e82fa1eb..35426bfb96a 100644
--- a/jstests/sharding/libs/resharding_test_fixture.js
+++ b/jstests/sharding/libs/resharding_test_fixture.js
@@ -38,6 +38,8 @@ var ReshardingTest = class {
maxNumberOfTransactionOperationsInSingleOplogEntry:
maxNumberOfTransactionOperationsInSingleOplogEntry = undefined,
configShard: configShard = false,
+ wiredTigerConcurrentWriteTransactions: wiredTigerConcurrentWriteTransactions = undefined,
+ reshardingOplogBatchTaskCount: reshardingOplogBatchTaskCount = undefined,
} = {}) {
// The @private JSDoc comments cause VS Code to not display the corresponding properties and
// methods in its autocomplete list. This makes it simpler for test authors to know what the
@@ -70,6 +72,8 @@ var ReshardingTest = class {
this._maxNumberOfTransactionOperationsInSingleOplogEntry =
maxNumberOfTransactionOperationsInSingleOplogEntry;
this._configShard = configShard || jsTestOptions().configShard;
+ this._wiredTigerConcurrentWriteTransactions = wiredTigerConcurrentWriteTransactions;
+ this._reshardingOplogBatchTaskCount = reshardingOplogBatchTaskCount;
// Properties set by setup().
/** @private */
@@ -186,6 +190,18 @@ var ReshardingTest = class {
Object.merge(configOptions.setParameter, rsOptions.setParameter);
}
+ if (this._wiredTigerConcurrentWriteTransactions !== undefined) {
+ rsOptions.setParameter.storageEngineConcurrencyAdjustmentAlgorithm =
+ "fixedConcurrentTransactions";
+ rsOptions.setParameter.wiredTigerConcurrentWriteTransactions =
+ this._wiredTigerConcurrentWriteTransactions;
+ }
+
+ if (this._reshardingOplogBatchTaskCount !== undefined) {
+ rsOptions.setParameter.reshardingOplogBatchTaskCount =
+ this._reshardingOplogBatchTaskCount;
+ }
+
this._st = new ShardingTest({
mongos: 1,
mongosOptions,
diff --git a/jstests/sharding/resharding_with_multi_deletes_reduced_ticket_pool_size.js b/jstests/sharding/resharding_with_multi_deletes_reduced_ticket_pool_size.js
new file mode 100644
index 00000000000..7b4d77c5291
--- /dev/null
+++ b/jstests/sharding/resharding_with_multi_deletes_reduced_ticket_pool_size.js
@@ -0,0 +1,50 @@
+/**
+ * Test the correctness of multiple deletes during resharding with a reduced ticket pool size.
+ *
+ * @tags: [
+ * requires_sharding,
+ * ]
+ */
+
+(function() {
+"use strict";
+
+load("jstests/libs/discover_topology.js");
+load("jstests/sharding/libs/resharding_test_fixture.js");
+
+const kNumWriteTickets = 5;
+const kReshardingOplogBatchTaskCount = 20;
+const reshardingTest = new ReshardingTest({
+ wiredTigerConcurrentWriteTransactions: kNumWriteTickets,
+ reshardingOplogBatchTaskCount: kReshardingOplogBatchTaskCount
+});
+
+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]}],
+});
+for (let i = 0; i < 100; i++) {
+ assert.commandWorked(sourceCollection.insert([{x: 1}]));
+}
+assert.commandWorked(sourceCollection.insert([{x: 3}, {x: 3}]));
+const mongos = sourceCollection.getMongo();
+const topology = DiscoverTopology.findConnectedNodes(mongos);
+const coordinator = new Mongo(topology.configsvr.nodes[0]);
+const recipientShardNames = reshardingTest.recipientShardNames;
+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();
+ assert.commandWorked(sourceCollection.remove({x: 1}, {justOne: false}));
+ });
+reshardingTest.teardown();
+})();