summaryrefslogtreecommitdiff
path: root/src/mongo/db/s
diff options
context:
space:
mode:
authorTommaso Tocci <tommaso.tocci@mongodb.com>2020-03-11 12:49:46 +0100
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-03-26 12:48:34 +0000
commit4382b9e9231ba5360e374e97df382f34602ccaa4 (patch)
tree685e458d138bea755f7f39608310062a0c78b5c9 /src/mongo/db/s
parent22eacd7b23b61850488dfdf5760d240725da5b79 (diff)
downloadmongo-4382b9e9231ba5360e374e97df382f34602ccaa4.tar.gz
SERVER-47103 Add OrphanCleanupPolicy parameter to getOwnershipFilter
Diffstat (limited to 'src/mongo/db/s')
-rw-r--r--src/mongo/db/s/collection_metadata_filtering_test.cpp9
-rw-r--r--src/mongo/db/s/collection_sharding_runtime.cpp3
-rw-r--r--src/mongo/db/s/collection_sharding_runtime.h3
-rw-r--r--src/mongo/db/s/collection_sharding_state.h10
-rw-r--r--src/mongo/db/s/collection_sharding_state_factory_embedded.cpp3
-rw-r--r--src/mongo/db/s/collection_sharding_state_factory_standalone.cpp3
-rw-r--r--src/mongo/db/s/op_observer_sharding_impl.cpp3
7 files changed, 23 insertions, 11 deletions
diff --git a/src/mongo/db/s/collection_metadata_filtering_test.cpp b/src/mongo/db/s/collection_metadata_filtering_test.cpp
index 572d19d356e..951ff41e089 100644
--- a/src/mongo/db/s/collection_metadata_filtering_test.cpp
+++ b/src/mongo/db/s/collection_metadata_filtering_test.cpp
@@ -138,7 +138,8 @@ TEST_F(CollectionMetadataFilteringTest, FilterDocumentsInTheFuture) {
AutoGetCollection autoColl(operationContext(), kNss, MODE_IS);
auto* const css = CollectionShardingState::get(operationContext(), kNss);
- testFilterFn(css->getOwnershipFilter(operationContext()));
+ testFilterFn(css->getOwnershipFilter(
+ operationContext(), CollectionShardingState::OrphanCleanupPolicy::kAllowOrphanCleanup));
}
// Verifies that a different set of documents is visible for a timestamp in the past
@@ -161,7 +162,8 @@ TEST_F(CollectionMetadataFilteringTest, FilterDocumentsInThePast) {
AutoGetCollection autoColl(operationContext(), kNss, MODE_IS);
auto* const css = CollectionShardingState::get(operationContext(), kNss);
- testFilterFn(css->getOwnershipFilter(operationContext()));
+ testFilterFn(css->getOwnershipFilter(
+ operationContext(), CollectionShardingState::OrphanCleanupPolicy::kAllowOrphanCleanup));
}
// Verifies that when accessing too far into the past we get the stale error
@@ -192,7 +194,8 @@ TEST_F(CollectionMetadataFilteringTest, FilterDocumentsTooFarInThePastThrowsStal
AutoGetCollection autoColl(operationContext(), kNss, MODE_IS);
auto* const css = CollectionShardingState::get(operationContext(), kNss);
- testFilterFn(css->getOwnershipFilter(operationContext()));
+ testFilterFn(css->getOwnershipFilter(
+ operationContext(), CollectionShardingState::OrphanCleanupPolicy::kAllowOrphanCleanup));
}
} // namespace
diff --git a/src/mongo/db/s/collection_sharding_runtime.cpp b/src/mongo/db/s/collection_sharding_runtime.cpp
index a7892bad128..999601e64f0 100644
--- a/src/mongo/db/s/collection_sharding_runtime.cpp
+++ b/src/mongo/db/s/collection_sharding_runtime.cpp
@@ -122,7 +122,8 @@ CollectionShardingRuntime* CollectionShardingRuntime::get_UNSAFE(ServiceContext*
return checked_cast<CollectionShardingRuntime*>(css);
}
-ScopedCollectionFilter CollectionShardingRuntime::getOwnershipFilter(OperationContext* opCtx) {
+ScopedCollectionFilter CollectionShardingRuntime::getOwnershipFilter(
+ OperationContext* opCtx, OrphanCleanupPolicy orphanCleanupPolicy) {
const auto optReceivedShardVersion = getOperationReceivedVersion(opCtx, _nss);
if (!optReceivedShardVersion)
return {kUnshardedCollection};
diff --git a/src/mongo/db/s/collection_sharding_runtime.h b/src/mongo/db/s/collection_sharding_runtime.h
index ddbf9683b7f..ebdde2fed05 100644
--- a/src/mongo/db/s/collection_sharding_runtime.h
+++ b/src/mongo/db/s/collection_sharding_runtime.h
@@ -82,7 +82,8 @@ public:
const UUID& collectionUuid,
ChunkRange orphanRange);
- ScopedCollectionFilter getOwnershipFilter(OperationContext* opCtx) override;
+ ScopedCollectionFilter getOwnershipFilter(OperationContext* opCtx,
+ OrphanCleanupPolicy orphanCleanupPolicy) override;
ScopedCollectionDescription getCollectionDescription() override;
diff --git a/src/mongo/db/s/collection_sharding_state.h b/src/mongo/db/s/collection_sharding_state.h
index 2b46af3274c..b61a7c2d845 100644
--- a/src/mongo/db/s/collection_sharding_state.h
+++ b/src/mongo/db/s/collection_sharding_state.h
@@ -100,8 +100,9 @@ public:
* the operation is not associated with a shard version (refer to
* OperationShardingState::isOperationVersioned for more info on that), returns an UNSHARDED
* metadata object.
- *
- * The intended users of this method are callers which need to perform filtering. Use
+ * If 'kDisallowOrphanCleanup' is passed as 'OrphanCleanupPolicy', the range deleter won't
+ * delete any orphan chunk associated with this ScopedCollectionFilter until the object is
+ * destroyed. The intended users of this method are callers which need to perform filtering. Use
* 'getCurrentMetadata' for other cases, like obtaining information about sharding-related
* properties of the collection are necessary that won't change under collection IX/IS lock
* (e.g., isSharded or the shard key).
@@ -109,7 +110,10 @@ public:
* The returned object is safe to access even after the collection lock has been dropped.
*/
- virtual ScopedCollectionFilter getOwnershipFilter(OperationContext* opCtx) = 0;
+ enum class OrphanCleanupPolicy { kDisallowOrphanCleanup, kAllowOrphanCleanup };
+
+ virtual ScopedCollectionFilter getOwnershipFilter(OperationContext* opCtx,
+ OrphanCleanupPolicy orphanCleanupPolicy) = 0;
/**
* See the comments for 'getOwnershipFilter' above for more information on this method.
diff --git a/src/mongo/db/s/collection_sharding_state_factory_embedded.cpp b/src/mongo/db/s/collection_sharding_state_factory_embedded.cpp
index c46090d2034..f7d8a860594 100644
--- a/src/mongo/db/s/collection_sharding_state_factory_embedded.cpp
+++ b/src/mongo/db/s/collection_sharding_state_factory_embedded.cpp
@@ -53,7 +53,8 @@ const auto kUnshardedCollection = std::make_shared<UnshardedCollection>();
class CollectionShardingStateStandalone final : public CollectionShardingState {
public:
- ScopedCollectionFilter getOwnershipFilter(OperationContext*) override {
+ ScopedCollectionFilter getOwnershipFilter(OperationContext*,
+ OrphanCleanupPolicy orphanCleanupPolicy) override {
return {kUnshardedCollection};
}
diff --git a/src/mongo/db/s/collection_sharding_state_factory_standalone.cpp b/src/mongo/db/s/collection_sharding_state_factory_standalone.cpp
index c2ca5dd0c47..6f0d1ffe00d 100644
--- a/src/mongo/db/s/collection_sharding_state_factory_standalone.cpp
+++ b/src/mongo/db/s/collection_sharding_state_factory_standalone.cpp
@@ -51,7 +51,8 @@ const auto kUnshardedCollection = std::make_shared<UnshardedCollection>();
class CollectionShardingStateStandalone final : public CollectionShardingState {
public:
- ScopedCollectionFilter getOwnershipFilter(OperationContext*) override {
+ ScopedCollectionFilter getOwnershipFilter(OperationContext*,
+ OrphanCleanupPolicy orphanCleanupPolicy) override {
return {kUnshardedCollection};
}
ScopedCollectionDescription getCollectionDescription() override {
diff --git a/src/mongo/db/s/op_observer_sharding_impl.cpp b/src/mongo/db/s/op_observer_sharding_impl.cpp
index 9e201306ee6..b65d2aba4e2 100644
--- a/src/mongo/db/s/op_observer_sharding_impl.cpp
+++ b/src/mongo/db/s/op_observer_sharding_impl.cpp
@@ -55,7 +55,8 @@ void assertIntersectingChunkHasNotMoved(OperationContext* opCtx,
if (!repl::ReadConcernArgs::get(opCtx).getArgsAtClusterTime())
return;
- const auto collectionFilter = csr->getOwnershipFilter(opCtx);
+ const auto collectionFilter = csr->getOwnershipFilter(
+ opCtx, CollectionShardingState::OrphanCleanupPolicy::kAllowOrphanCleanup);
if (!collectionFilter.isSharded())
return;