diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2020-04-10 04:22:44 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-04-14 06:30:56 +0000 |
commit | 53b6694ef172411cfe8f5939b010efa35dd4d651 (patch) | |
tree | ff57436f2f702b8edd4212da8c3ce5d72e5d77eb /src/mongo/db/s/op_observer_sharding_impl.cpp | |
parent | f32f2f906f8c37145ed2bf64cd8db99d35671a41 (diff) | |
download | mongo-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.cpp | 16 |
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. |