summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo')
-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();