summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/op_observer_sharding_impl.cpp
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2020-04-10 04:22:44 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-04-14 06:30:56 +0000
commit53b6694ef172411cfe8f5939b010efa35dd4d651 (patch)
treeff57436f2f702b8edd4212da8c3ce5d72e5d77eb /src/mongo/db/s/op_observer_sharding_impl.cpp
parentf32f2f906f8c37145ed2bf64cd8db99d35671a41 (diff)
downloadmongo-53b6694ef172411cfe8f5939b010efa35dd4d651.tar.gz
SERVER-47468 Remove public CollectionMetadata references from ScopedCollectionDescription
The CollectionMetadata is intended to be an entirely internal (to sharding) implementation detail of the services provided by ScopedCollectionDescription/ScopedOwnershipFilter so should not be seen at all by non-sharding code.
Diffstat (limited to 'src/mongo/db/s/op_observer_sharding_impl.cpp')
-rw-r--r--src/mongo/db/s/op_observer_sharding_impl.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/mongo/db/s/op_observer_sharding_impl.cpp b/src/mongo/db/s/op_observer_sharding_impl.cpp
index 393c6bcaed7..c6eb5abab8e 100644
--- a/src/mongo/db/s/op_observer_sharding_impl.cpp
+++ b/src/mongo/db/s/op_observer_sharding_impl.cpp
@@ -52,18 +52,22 @@ const auto getIsMigrating = OperationContext::declareDecoration<bool>();
void assertIntersectingChunkHasNotMoved(OperationContext* opCtx,
CollectionShardingRuntime* csr,
const BSONObj& doc) {
- if (!repl::ReadConcernArgs::get(opCtx).getArgsAtClusterTime())
+ const auto atClusterTime = repl::ReadConcernArgs::get(opCtx).getArgsAtClusterTime();
+ if (!atClusterTime)
return;
- const auto collectionFilter = csr->getOwnershipFilter(
- opCtx, CollectionShardingState::OrphanCleanupPolicy::kAllowOrphanCleanup);
- if (!collectionFilter.isSharded())
+ // TODO (SERVER-47472): The execution leading to here will guarantee that the metadata is always
+ // known, so the !metadata check can be removed
+ auto metadata = csr->getCurrentMetadataIfKnown();
+ if (!metadata || !metadata->isSharded())
return;
- auto shardKey = collectionFilter.extractShardKeyFromDoc(doc);
+ auto shardKey = metadata->getShardKeyPattern().extractShardKeyFromDoc(doc);
// We can assume the simple collation because shard keys do not support non-simple collations.
- auto chunk = collectionFilter.findIntersectingChunkWithSimpleCollation(shardKey);
+ ChunkManager chunkManagerAtClusterTime(metadata->getChunkManager()->getRoutingHistory(),
+ atClusterTime->asTimestamp());
+ auto chunk = chunkManagerAtClusterTime.findIntersectingChunkWithSimpleCollation(shardKey);
// Throws if the chunk has moved since the timestamp of the running transaction's atClusterTime
// read concern parameter.