summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierlauro Sciarelli <pierlauro.sciarelli@mongodb.com>2023-01-09 07:03:32 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-01-09 07:35:52 +0000
commitad0c764b6f5020033092a91164e0187add0deb94 (patch)
tree097361fc42a17135af4621d6222c40a05a8af337
parent2832fd105188727ddfd3f77370cb344257bf8518 (diff)
downloadmongo-ad0c764b6f5020033092a91164e0187add0deb94.tar.gz
SERVER-72290 `deleteRangeDeletionTasksForRename` must not deregister tasks for the target collection
-rw-r--r--src/mongo/db/s/range_deletion_util.cpp5
-rw-r--r--src/mongo/db/s/range_deletion_util_test.cpp54
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 c34400e7590..15c06d17d9d 100644
--- a/src/mongo/db/s/range_deletion_util.cpp
+++ b/src/mongo/db/s/range_deletion_util.cpp
@@ -456,11 +456,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 c7854ad1d6b..3845c11af77 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
@@ -933,19 +936,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