summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEsha Maharishi <esha.maharishi@mongodb.com>2020-02-05 18:18:54 +0000
committerevergreen <evergreen@mongodb.com>2020-02-05 18:18:54 +0000
commitd8b5b7e7d954919155f9841ba181b26f56e436db (patch)
tree8f21e6a446f621860114b766dedbeafeb135f8c2
parent25833d97dea9035675d92e3f856bc42257193e65 (diff)
downloadmongo-d8b5b7e7d954919155f9841ba181b26f56e436db.tar.gz
SERVER-45740 submitRangeDeletionTask should delete range deletion task if filtering metadata is still unknown after refresh
-rw-r--r--src/mongo/db/s/migration_util.cpp11
-rw-r--r--src/mongo/db/s/migration_util_test.cpp23
2 files changed, 33 insertions, 1 deletions
diff --git a/src/mongo/db/s/migration_util.cpp b/src/mongo/db/s/migration_util.cpp
index f99f37ed79d..f539a715804 100644
--- a/src/mongo/db/s/migration_util.cpp
+++ b/src/mongo/db/s/migration_util.cpp
@@ -161,7 +161,16 @@ ExecutorFuture<bool> submitRangeDeletionTask(OperationContext* opCtx,
// forceShardFilteringMetadataRefresh to avoid blocking on the network in the
// thread pool.
autoColl.reset();
- forceShardFilteringMetadataRefresh(opCtx, deletionTask.getNss(), true);
+ try {
+ forceShardFilteringMetadataRefresh(opCtx, deletionTask.getNss(), true);
+ } catch (const DBException& ex) {
+ if (ex.toStatus() == ErrorCodes::NamespaceNotFound) {
+ deleteRangeDeletionTaskLocally(
+ opCtx, deletionTask.getId(), ShardingCatalogClient::kLocalWriteConcern);
+ return false;
+ }
+ throw;
+ }
}
autoColl.emplace(opCtx, deletionTask.getNss(), MODE_IS);
diff --git a/src/mongo/db/s/migration_util_test.cpp b/src/mongo/db/s/migration_util_test.cpp
index e6e4deaebbd..2aafa4e6c5f 100644
--- a/src/mongo/db/s/migration_util_test.cpp
+++ b/src/mongo/db/s/migration_util_test.cpp
@@ -378,6 +378,29 @@ 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.
+ 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();