summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEsha Maharishi <esha.maharishi@mongodb.com>2020-01-24 15:56:42 +0000
committerevergreen <evergreen@mongodb.com>2020-01-24 15:56:42 +0000
commitba1b7bfcc7bc133fcb3ebf6ea44c6a55edab0bea (patch)
tree3bf37e401f2c7f632f130099e4fa1e0fee622d13
parentd96b36f6f6de51618d1dc300c599576f0da4e00d (diff)
downloadmongo-ba1b7bfcc7bc133fcb3ebf6ea44c6a55edab0bea.tar.gz
SERVER-45749 Tests in range_deletion_util_test.cpp that insert into config.rangeDeletions should set the collection's filtering metadata before the insert
-rw-r--r--src/mongo/db/s/migration_util.cpp4
-rw-r--r--src/mongo/db/s/range_deletion_util_test.cpp31
2 files changed, 31 insertions, 4 deletions
diff --git a/src/mongo/db/s/migration_util.cpp b/src/mongo/db/s/migration_util.cpp
index 964addcd78f..d98acf3f32d 100644
--- a/src/mongo/db/s/migration_util.cpp
+++ b/src/mongo/db/s/migration_util.cpp
@@ -151,8 +151,8 @@ ExecutorFuture<bool> submitRangeDeletionTask(OperationContext* opCtx,
LOG(0) << "Filtering metadata for namespace in deletion task "
<< deletionTask.toBSON()
<< (css->getCurrentMetadataIfKnown()
- ? "has UUID that does not match UUID of the deletion task"
- : "is not known")
+ ? " has UUID that does not match UUID of the deletion task"
+ : " is not known")
<< ", forcing a refresh of " << deletionTask.getNss();
// TODO (SERVER-45577): Add an asynchronous version of
diff --git a/src/mongo/db/s/range_deletion_util_test.cpp b/src/mongo/db/s/range_deletion_util_test.cpp
index a2d245e185c..f66d983a26e 100644
--- a/src/mongo/db/s/range_deletion_util_test.cpp
+++ b/src/mongo/db/s/range_deletion_util_test.cpp
@@ -31,6 +31,8 @@
#include "mongo/db/db_raii.h"
#include "mongo/db/dbdirectclient.h"
+#include "mongo/db/s/collection_sharding_runtime.h"
+#include "mongo/db/s/metadata_manager.h"
#include "mongo/db/s/persistent_task_store.h"
#include "mongo/db/s/range_deletion_task_gen.h"
#include "mongo/db/s/range_deletion_util.h"
@@ -82,6 +84,28 @@ public:
ShardServerTestFixture::tearDown();
}
+ void setFilteringMetadataWithUUID(const UUID& uuid) {
+ const OID epoch = OID::gen();
+
+ auto rt = RoutingTableHistory::makeNew(
+ kNss,
+ uuid,
+ kShardKeyPattern,
+ nullptr,
+ false,
+ epoch,
+ {ChunkType{kNss,
+ ChunkRange{BSON(kShardKey << MINKEY), BSON(kShardKey << MAXKEY)},
+ ChunkVersion(1, 0, epoch),
+ ShardId("dummyShardId")}});
+
+ std::shared_ptr<ChunkManager> cm = std::make_shared<ChunkManager>(rt, boost::none);
+
+ CollectionShardingRuntime::get(operationContext(), kNss)
+ ->setFilteringMetadata(operationContext(),
+ CollectionMetadata(cm, ShardId("dummyShardId")));
+ }
+
UUID uuid() const {
return _uuid;
}
@@ -421,9 +445,9 @@ TEST_F(RangeDeleterTest, RemoveDocumentsInRangeRetriesOnWriteConflictException)
dbclient.insert(kNss.toString(), BSON(kShardKey << 5));
// Insert range deletion task for this collection and range.
+ setFilteringMetadataWithUUID(uuid());
PersistentTaskStore<RangeDeletionTask> store(operationContext(),
NamespaceString::kRangeDeletionNamespace);
-
RangeDeletionTask t(
UUID::gen(), kNss, uuid(), ShardId("donor"), range, CleanWhenEnum::kDelayed);
store.add(operationContext(), t);
@@ -459,9 +483,9 @@ TEST_F(RangeDeleterTest, RemoveDocumentsInRangeRetriesOnUnexpectedError) {
dbclient.insert(kNss.toString(), BSON(kShardKey << 5));
// Insert range deletion task for this collection and range.
+ setFilteringMetadataWithUUID(uuid());
PersistentTaskStore<RangeDeletionTask> store(operationContext(),
NamespaceString::kRangeDeletionNamespace);
-
RangeDeletionTask t(
UUID::gen(), kNss, uuid(), ShardId("donor"), range, CleanWhenEnum::kDelayed);
store.add(operationContext(), t);
@@ -576,6 +600,7 @@ TEST_F(RangeDeleterTest, RemoveDocumentsInRangeRemovesRangeDeletionTaskOnSuccess
dbclient.insert(kNss.toString(), BSON(kShardKey << 5));
// Insert range deletion task for this collection and range.
+ setFilteringMetadataWithUUID(uuid());
PersistentTaskStore<RangeDeletionTask> store(operationContext(),
NamespaceString::kRangeDeletionNamespace);
@@ -613,6 +638,7 @@ TEST_F(RangeDeleterTest,
dbclient.insert(kNss.toString(), BSON(kShardKey << 5));
// Insert range deletion task for this collection and range.
+ setFilteringMetadataWithUUID(fakeUuid);
PersistentTaskStore<RangeDeletionTask> store(operationContext(),
NamespaceString::kRangeDeletionNamespace);
@@ -650,6 +676,7 @@ TEST_F(RangeDeleterTest,
dbclient.insert(kNss.toString(), BSON(kShardKey << 5));
// Insert range deletion task for this collection and range.
+ setFilteringMetadataWithUUID(uuid());
PersistentTaskStore<RangeDeletionTask> store(operationContext(),
NamespaceString::kRangeDeletionNamespace);