summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog/collection.cpp
diff options
context:
space:
mode:
authorDianna Hohensee <dianna.hohensee@mongodb.com>2020-10-23 01:48:29 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-12-16 06:55:42 +0000
commit0efb63b64441f935b5d06f4180d0969434327551 (patch)
treec80b550b5d0e5ee8e9220c144877dc98e573b09b /src/mongo/db/catalog/collection.cpp
parent6019169e828c7100cd72ac617ab0ce579b20c957 (diff)
downloadmongo-0efb63b64441f935b5d06f4180d0969434327551.tar.gz
SERVER-51319 Call DatabaseShardingState::checkDbVersion() and CSS::getCollectionDescription() safely in AutoGetCollectionLockFree and expand lock-free sharding testing.
CollectionShardingState and DatabaseShardingState can now be accessed without a lock via new getSharedForLockFreeReads() functions on their respective interfaces. The shard key will now be available in the AutoGetCollection* RAII types via the CollectionPtr. This allows lock-free reads to acquire a single view of the sharding state to use throughout a read operation.
Diffstat (limited to 'src/mongo/db/catalog/collection.cpp')
-rw-r--r--src/mongo/db/catalog/collection.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/mongo/db/catalog/collection.cpp b/src/mongo/db/catalog/collection.cpp
index 5a4eeb5c584..59513b73ad1 100644
--- a/src/mongo/db/catalog/collection.cpp
+++ b/src/mongo/db/catalog/collection.cpp
@@ -103,6 +103,11 @@ void CollectionPtr::restore() const {
}
}
+const BSONObj& CollectionPtr::getShardKeyPattern() const {
+ dassert(_shardKeyPattern);
+ return _shardKeyPattern.get();
+}
+
// ----
namespace {