diff options
author | Max Hirschhorn <max.hirschhorn@mongodb.com> | 2016-05-31 12:11:37 -0400 |
---|---|---|
committer | Max Hirschhorn <max.hirschhorn@mongodb.com> | 2016-05-31 12:11:37 -0400 |
commit | 9e179455c3efc0781c7b4d12e121ec6b6459fa3a (patch) | |
tree | 6e81d22f2a3f4782091c87fca0fa7de5c4d76d5e | |
parent | f242be85e80794d009eb151c9ea2184ceb8d3d81 (diff) | |
download | mongo-9e179455c3efc0781c7b4d12e121ec6b6459fa3a.tar.gz |
SERVER-24313 Acquire lock when RS backing KVCatalog isn't thread-safe.
(cherry picked from commit 4f88b7bb4eaf82b2607dfe450120df6aa5e54f5e)
Also acquires the resource lock in hasNoFeaturesMarkedAsInUse() when the
storage engine doesn't support document-level concurrency.
-rw-r--r-- | src/mongo/db/storage/kv/kv_catalog.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/mongo/db/storage/kv/kv_catalog.cpp b/src/mongo/db/storage/kv/kv_catalog.cpp index 46616bed02d..d60655c526e 100644 --- a/src/mongo/db/storage/kv/kv_catalog.cpp +++ b/src/mongo/db/storage/kv/kv_catalog.cpp @@ -44,6 +44,7 @@ #include "mongo/db/storage/recovery_unit.h" #include "mongo/platform/bits.h" #include "mongo/platform/random.h" +#include "mongo/stdx/memory.h" #include "mongo/util/log.h" #include "mongo/util/mongoutils/str.h" @@ -122,6 +123,12 @@ bool KVCatalog::FeatureTracker::isFeatureDocument(BSONObj obj) { } Status KVCatalog::FeatureTracker::isCompatibleWithCurrentCode(OperationContext* opCtx) const { + std::unique_ptr<Lock::ResourceLock> rLk; + if (!_catalog->_isRsThreadSafe && opCtx->lockState()) { + rLk = stdx::make_unique<Lock::ResourceLock>( + opCtx->lockState(), resourceIdCatalogMetadata, MODE_S); + } + FeatureBits versionInfo = getInfo(opCtx); uint64_t unrecognizedNonRepairableFeatures = @@ -150,6 +157,12 @@ Status KVCatalog::FeatureTracker::isCompatibleWithCurrentCode(OperationContext* } Status KVCatalog::FeatureTracker::hasNoFeaturesMarkedAsInUse(OperationContext* opCtx) const { + std::unique_ptr<Lock::ResourceLock> rLk; + if (!_catalog->_isRsThreadSafe && opCtx->lockState()) { + rLk = stdx::make_unique<Lock::ResourceLock>( + opCtx->lockState(), resourceIdCatalogMetadata, MODE_S); + } + FeatureBits versionInfo = getInfo(opCtx); if (versionInfo.nonRepairableFeatures) { |