diff options
author | Pierlauro Sciarelli <pierlauro.sciarelli@mongodb.com> | 2023-01-09 07:03:32 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-01-09 16:28:34 +0000 |
commit | d90c776681c904ded016d62108c17fd3e605f6ae (patch) | |
tree | 99d48f5879689b1a2c0cf7e18cb4d3d194dad042 | |
parent | a31c4c6c4bb1d0d066ca5edbe2345425b61a498b (diff) | |
download | mongo-d90c776681c904ded016d62108c17fd3e605f6ae.tar.gz |
SERVER-72290 `deleteRangeDeletionTasksForRename` must not deregister tasks for the target collection
-rw-r--r-- | src/mongo/db/s/range_deletion_util.cpp | 5 | ||||
-rw-r--r-- | src/mongo/db/s/range_deletion_util_test.cpp | 54 |
2 files changed, 30 insertions, 29 deletions
diff --git a/src/mongo/db/s/range_deletion_util.cpp b/src/mongo/db/s/range_deletion_util.cpp index 707516db64f..16427d9e393 100644 --- a/src/mongo/db/s/range_deletion_util.cpp +++ b/src/mongo/db/s/range_deletion_util.cpp @@ -451,11 +451,6 @@ void restoreRangeDeletionTasksForRename(OperationContext* opCtx, const Namespace void deleteRangeDeletionTasksForRename(OperationContext* opCtx, const NamespaceString& fromNss, const NamespaceString& toNss) { - // Delete range deletion tasks associated to the source collection - PersistentTaskStore<RangeDeletionTask> rangeDeletionsStore( - NamespaceString::kRangeDeletionNamespace); - rangeDeletionsStore.remove(opCtx, BSON(RangeDeletionTask::kNssFieldName << fromNss.ns())); - // Delete already restored snapshots associated to the target collection PersistentTaskStore<RangeDeletionTask> rangeDeletionsForRenameStore( NamespaceString::kRangeDeletionForRenameNamespace); diff --git a/src/mongo/db/s/range_deletion_util_test.cpp b/src/mongo/db/s/range_deletion_util_test.cpp index 625f0dcafc3..2aa966e97d4 100644 --- a/src/mongo/db/s/range_deletion_util_test.cpp +++ b/src/mongo/db/s/range_deletion_util_test.cpp @@ -876,19 +876,22 @@ TEST_F(RenameRangeDeletionsTest, BasicRenameRangeDeletionsTest) { restoreRangeDeletionTasksForRename(_opCtx, kToNss); deleteRangeDeletionTasksForRename(_opCtx, kNss, kToNss); - // Make sure just range deletions for the TO collection are found - ASSERT_EQ(10, rangeDeletionsStore.count(_opCtx)); + const auto targetRangeDeletionsQuery = BSON(RangeDeletionTask::kNssFieldName << kToNss.ns()); + + // Make sure range deletions for the TO collection are found + ASSERT_EQ(10, rangeDeletionsStore.count(_opCtx, targetRangeDeletionsQuery)); int foundTasks = 0; - rangeDeletionsStore.forEach(_opCtx, BSONObj(), [&](const RangeDeletionTask& newTask) { - auto task = tasks.at(foundTasks++); - ASSERT_EQ(newTask.getNss(), kToNss); - ASSERT_EQ(newTask.getCollectionUuid(), task.getCollectionUuid()); - ASSERT_EQ(newTask.getDonorShardId(), task.getDonorShardId()); - ASSERT(SimpleBSONObjComparator::kInstance.evaluate(newTask.getRange().toBSON() == - task.getRange().toBSON())); - ASSERT(newTask.getWhenToClean() == task.getWhenToClean()); - return true; - }); + rangeDeletionsStore.forEach( + _opCtx, targetRangeDeletionsQuery, [&](const RangeDeletionTask& newTask) { + auto task = tasks.at(foundTasks++); + ASSERT_EQ(newTask.getNss(), kToNss); + ASSERT_EQ(newTask.getCollectionUuid(), task.getCollectionUuid()); + ASSERT_EQ(newTask.getDonorShardId(), task.getDonorShardId()); + ASSERT(SimpleBSONObjComparator::kInstance.evaluate(newTask.getRange().toBSON() == + task.getRange().toBSON())); + ASSERT(newTask.getWhenToClean() == task.getWhenToClean()); + return true; + }); ASSERT_EQ(foundTasks, numTasks); // Make sure no garbage is left in intermediate collection @@ -928,19 +931,22 @@ TEST_F(RenameRangeDeletionsTest, IdempotentRenameRangeDeletionsTest) { deleteRangeDeletionTasksForRename(_opCtx, kNss, kToNss); } - // Make sure just range deletions for the TO collection are found - ASSERT_EQ(10, rangeDeletionsStore.count(_opCtx)); + const auto targetRangeDeletionsQuery = BSON(RangeDeletionTask::kNssFieldName << kToNss.ns()); + + // Make sure range deletions for the TO collection are found + ASSERT_EQ(10, rangeDeletionsStore.count(_opCtx, targetRangeDeletionsQuery)); int foundTasks = 0; - rangeDeletionsStore.forEach(_opCtx, BSONObj(), [&](const RangeDeletionTask& newTask) { - auto task = tasks.at(foundTasks++); - ASSERT_EQ(newTask.getNss(), kToNss); - ASSERT_EQ(newTask.getCollectionUuid(), task.getCollectionUuid()); - ASSERT_EQ(newTask.getDonorShardId(), task.getDonorShardId()); - ASSERT(SimpleBSONObjComparator::kInstance.evaluate(newTask.getRange().toBSON() == - task.getRange().toBSON())); - ASSERT(newTask.getWhenToClean() == task.getWhenToClean()); - return true; - }); + rangeDeletionsStore.forEach( + _opCtx, targetRangeDeletionsQuery, [&](const RangeDeletionTask& newTask) { + auto task = tasks.at(foundTasks++); + ASSERT_EQ(newTask.getNss(), kToNss); + ASSERT_EQ(newTask.getCollectionUuid(), task.getCollectionUuid()); + ASSERT_EQ(newTask.getDonorShardId(), task.getDonorShardId()); + ASSERT(SimpleBSONObjComparator::kInstance.evaluate(newTask.getRange().toBSON() == + task.getRange().toBSON())); + ASSERT(newTask.getWhenToClean() == task.getWhenToClean()); + return true; + }); ASSERT_EQ(foundTasks, numTasks); // Make sure no garbage is left in intermediate collection |