From 1af652b3871a61b3b731c68008c35258b0480218 Mon Sep 17 00:00:00 2001 From: Jordi Serra Torrens Date: Fri, 7 Oct 2022 07:53:53 +0000 Subject: [PATCH] Repro SERVER-70322 --- jstests/sharding/repro-server-70322.js | 38 ++++++++++++++++++++++++++ src/mongo/db/s/range_deletion_util.cpp | 4 +++ 2 files changed, 42 insertions(+) create mode 100644 jstests/sharding/repro-server-70322.js diff --git a/jstests/sharding/repro-server-70322.js b/jstests/sharding/repro-server-70322.js new file mode 100644 index 00000000000..24f104188d7 --- /dev/null +++ b/jstests/sharding/repro-server-70322.js @@ -0,0 +1,38 @@ +(function() { +'use strict'; + +load('jstests/libs/fail_point_util.js'); +load('jstests/libs/parallel_shell_helpers.js'); + +const dbName = 'test'; +const collName = 'foo'; +const ns = dbName + '.' + collName; + +const st = new ShardingTest({shards: 2}); + +assert.commandWorked( + st.s.adminCommand({enableSharding: dbName, primaryShard: st.shard0.shardName})); +assert.commandWorked(st.s.adminCommand({shardCollection: ns, key: {_id: 1}})); + +const coll = st.s.getCollection(ns); +assert.commandWorked(coll.insert({x: 1})); + +let hangPersistUpdatedNumOrphansWhileHoldingRangeDeleterLock = configureFailPoint(st.shard1, 'hangPersistUpdatedNumOrphansWhileHoldingRangeDeleterLock'); + +const awaitResult = startParallelShell( + funWithArgs(function(ns, toShardName) { + assert.commandWorked( + db.adminCommand({moveChunk: ns, find: {_id: 0}, to: toShardName})); + }, ns, st.shard1.shardName), st.s.port); + +hangPersistUpdatedNumOrphansWhileHoldingRangeDeleterLock.wait(); + +jsTest.log("--XXXX-- hit fp"); + +assert.commandWorked(st.rs1.getPrimary().adminCommand({lockInfo: 1})); + +hangPersistUpdatedNumOrphansWhileHoldingRangeDeleterLock.off(); +awaitResult(); + +st.stop(); +})(); diff --git a/src/mongo/db/s/range_deletion_util.cpp b/src/mongo/db/s/range_deletion_util.cpp index aeda613b823..cd96e14a46f 100644 --- a/src/mongo/db/s/range_deletion_util.cpp +++ b/src/mongo/db/s/range_deletion_util.cpp @@ -73,6 +73,7 @@ MONGO_FAIL_POINT_DEFINE(hangAfterDoingDeletion); MONGO_FAIL_POINT_DEFINE(suspendRangeDeletion); MONGO_FAIL_POINT_DEFINE(throwWriteConflictExceptionInDeleteRange); MONGO_FAIL_POINT_DEFINE(throwInternalErrorInDeleteRange); +MONGO_FAIL_POINT_DEFINE(hangPersistUpdatedNumOrphansWhileHoldingRangeDeleterLock); /** * Performs the deletion of up to numDocsToRemovePerBatch entries within the range in progress. Must @@ -582,6 +583,9 @@ void persistUpdatedNumOrphans(OperationContext* opCtx, try { PersistentTaskStore store(NamespaceString::kRangeDeletionNamespace); ScopedRangeDeleterLock rangeDeleterLock(opCtx, collectionUuid); + + hangPersistUpdatedNumOrphansWhileHoldingRangeDeleterLock.pauseWhileSet(); + // The DBDirectClient will not retry WriteConflictExceptions internally while holding an X // mode lock, so we need to retry at this level. writeConflictRetry( -- 2.17.1