[SERVER-45740] submitRangeDeletionTask should delete range deletion task if filtering metadata is still unknown after refresh Created: 24/Jan/20  Updated: 29/Oct/23  Resolved: 05/Feb/20

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: None
Fix Version/s: 4.3.4

Type: Task Priority: Major - P3
Reporter: Esha Maharishi (Inactive) Assignee: Esha Maharishi (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Backwards Compatibility: Fully Compatible
Sprint: Sharding 2020-02-10
Participants:
Linked BF Score: 21

 Description   

submitRangeDeletionTask does not correctly handle the case where forceShardFilteringMetadataRefresh throws NamespaceNotFound. In this case, the range deletion task should be deleted, but the code to do that will not execute. I can confirm this by applying the following diff, which contains a unit test that demonstrates the incorrect behavior:

diff --git a/src/mongo/db/s/migration_util_test.cpp b/src/mongo/db/s/migration_util_test.cpp
index e6e4deaebb..001c307bbb 100644
--- a/src/mongo/db/s/migration_util_test.cpp
+++ b/src/mongo/db/s/migration_util_test.cpp
@@ -378,6 +378,31 @@ TEST_F(MigrationUtilsTest, TestInvalidUUID) {
 
 using SubmitRangeDeletionTaskTest = MigrationUtilsTest;
 
+TEST_F(SubmitRangeDeletionTaskTest,
+       FailsAndDeletesTaskIfFilteringMetadataIsUnknownEvenAfterRefresh) {
+    auto opCtx = operationContext();
+
+    const auto uuid = UUID::gen();
+    auto deletionTask = createDeletionTask(kNss, uuid, 0, 10);
+
+    PersistentTaskStore<RangeDeletionTask> store(opCtx, NamespaceString::kRangeDeletionNamespace);
+    store.add(opCtx, deletionTask);
+    ASSERT_EQ(store.count(opCtx), 1);
+
+    // Make the refresh triggered by submitting the task return an empty result so that .
+    auto result =
+        stdx::async(stdx::launch::async, [this, uuid] {
+        respondToMetadataRefreshRequestsWithError();
+    });
+
+    auto submitTaskFuture = migrationutil::submitRangeDeletionTask(opCtx, deletionTask);
+
+    // The task should not have been submitted, and the task's entry should have been removed from
+    // the persistent store.
+    ASSERT_FALSE(submitTaskFuture.get(opCtx));
+    ASSERT_EQ(store.count(opCtx), 0);
+}
+
 TEST_F(SubmitRangeDeletionTaskTest, SucceedsIfFilteringMetadataUUIDMatchesTaskUUID) {
     auto opCtx = operationContext();



 Comments   
Comment by Githook User [ 05/Feb/20 ]

Author:

{'username': 'EshaMaharishi', 'name': 'Esha Maharishi', 'email': 'esha.maharishi@mongodb.com'}

Message: SERVER-45740 submitRangeDeletionTask should delete range deletion task if filtering metadata is still unknown after refresh
Branch: master
https://github.com/mongodb/mongo/commit/d8b5b7e7d954919155f9841ba181b26f56e436db

Comment by Esha Maharishi (Inactive) [ 24/Jan/20 ]

Marking as related to BF-15914, since that's where I discovered this issue.

Generated at Thu Feb 08 05:09:35 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.