From 637e7a79d62cc7880b719f02db3316c21eb3a5da Mon Sep 17 00:00:00 2001 From: nandinibhartiyaMDB Date: Tue, 2 May 2023 22:26:28 +0000 Subject: [PATCH] SERVER-123: Fix delete ops of oplog application --- .../sharding/libs/resharding_test_fixture.js | 9 ++++ ..._multi_deletes_reduced_ticket_pool_size.js | 48 +++++++++++++++++++ .../s/resharding/resharding_oplog_applier.cpp | 1 - .../resharding_server_parameters.idl | 2 +- 4 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 jstests/sharding/resharding_with_multi_deletes_reduced_ticket_pool_size.js diff --git a/jstests/sharding/libs/resharding_test_fixture.js b/jstests/sharding/libs/resharding_test_fixture.js index e05e82fa1eb..2fdb845d0b5 100644 --- a/jstests/sharding/libs/resharding_test_fixture.js +++ b/jstests/sharding/libs/resharding_test_fixture.js @@ -35,6 +35,7 @@ var ReshardingTest = class { logComponentVerbosity: logComponentVerbosity = undefined, storeFindAndModifyImagesInSideCollection: storeFindAndModifyImagesInSideCollection = true, oplogSize: oplogSize = undefined, + wiredTigerConcurrentWriteTransactions: wiredTigerConcurrentWriteTransactions = undefined, maxNumberOfTransactionOperationsInSingleOplogEntry: maxNumberOfTransactionOperationsInSingleOplogEntry = undefined, configShard: configShard = false, @@ -67,6 +68,7 @@ var ReshardingTest = class { /** @private */ this._storeFindAndModifyImagesInSideCollection = storeFindAndModifyImagesInSideCollection; this._oplogSize = oplogSize; + this._wiredTigerConcurrentWriteTransactions = wiredTigerConcurrentWriteTransactions; this._maxNumberOfTransactionOperationsInSingleOplogEntry = maxNumberOfTransactionOperationsInSingleOplogEntry; this._configShard = configShard || jsTestOptions().configShard; @@ -172,6 +174,13 @@ var ReshardingTest = class { mongosOptions.setParameter.logComponentVerbosity = this._logComponentVerbosity; } + if (this._wiredTigerConcurrentWriteTransactions !== undefined) { + rsOptions.setParameter.storageEngineConcurrencyAdjustmentAlgorithm = + "fixedConcurrentTransactions"; + rsOptions.setParameter.wiredTigerConcurrentWriteTransactions = + this._wiredTigerConcurrentWriteTransactions; + } + if (this._maxNumberOfTransactionOperationsInSingleOplogEntry !== undefined) { rsOptions.setParameter.maxNumberOfTransactionOperationsInSingleOplogEntry = this._maxNumberOfTransactionOperationsInSingleOplogEntry; 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..f1ec4af65fd --- /dev/null +++ b/jstests/sharding/resharding_with_multi_deletes_reduced_ticket_pool_size.js @@ -0,0 +1,48 @@ +/** + * Test the correctness of multi deletes during resharding. + * + * @tags: [ + * requires_sharding, + * ] + */ + +(function() { +"use strict"; + +load("jstests/libs/discover_topology.js"); +load("jstests/sharding/libs/resharding_test_fixture.js"); + +const kNumWriteTickets = 5; +const reshardingTest = + new ReshardingTest({wiredTigerConcurrentWriteTransactions: kNumWriteTickets}); + +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 < 10; 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(); +})(); diff --git a/src/mongo/db/s/resharding/resharding_oplog_applier.cpp b/src/mongo/db/s/resharding/resharding_oplog_applier.cpp index 51632cb40cc..4f4d1f1b035 100644 --- a/src/mongo/db/s/resharding/resharding_oplog_applier.cpp +++ b/src/mongo/db/s/resharding/resharding_oplog_applier.cpp @@ -90,7 +90,6 @@ SemiFuture ReshardingOplogApplier::_applyBatch( // though allows CRUD application to be concurrent with preparing the writer vectors for session // application in addition to being concurrent with session application itself. batchApplierFutures.reserve(2 * crudWriterVectors.size()); - for (auto&& writer : crudWriterVectors) { if (!writer.empty()) { batchApplierFutures.emplace_back( diff --git a/src/mongo/db/s/resharding/resharding_server_parameters.idl b/src/mongo/db/s/resharding/resharding_server_parameters.idl index ea5703cf34d..644df507a06 100644 --- a/src/mongo/db/s/resharding/resharding_server_parameters.idl +++ b/src/mongo/db/s/resharding/resharding_server_parameters.idl @@ -60,7 +60,7 @@ server_parameters: set_at: startup cpp_vartype: int cpp_varname: gReshardingRecipientServiceMaxThreadCount - default: 8 + default: 20 validator: gte: 1 lte: 256 -- 2.17.1