diff options
author | Dianna Hohensee <dianna.hohensee@mongodb.com> | 2020-12-17 16:03:17 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-12-18 23:47:25 +0000 |
commit | bd06aabdb67dca10663b7d48fff47e12c5925ac6 (patch) | |
tree | 966b79ecec043af93e83eedeef0dd72c7db8e074 /src/mongo/db/catalog_raii.cpp | |
parent | 49b56d28633d5fbfb090ed91e90b9c975ba61190 (diff) | |
download | mongo-bd06aabdb67dca10663b7d48fff47e12c5925ac6.tar.gz |
SERVER-53427 Infrastructure changes to support nested LFR operations
1) Create a nested lock helper to run lock-free if a higher level lock-free operation is already running.
2) Change LockFreeReadsBlock to use a counter rather than a boolean to accommodate out of order lock helper destructors.
3) Only yield lock-free read state in query yield when NOT recursively locked.
4) Change query stages and plan executor to use new nested lock-free lock helper.
Diffstat (limited to 'src/mongo/db/catalog_raii.cpp')
-rw-r--r-- | src/mongo/db/catalog_raii.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/mongo/db/catalog_raii.cpp b/src/mongo/db/catalog_raii.cpp index 002fbaeda87..841b4a8c43f 100644 --- a/src/mongo/db/catalog_raii.cpp +++ b/src/mongo/db/catalog_raii.cpp @@ -27,6 +27,8 @@ * it in the license file. */ +#define MONGO_LOGV2_DEFAULT_COMPONENT ::mongo::logv2::LogComponent::kStorage + #include "mongo/platform/basic.h" #include "mongo/db/catalog_raii.h" @@ -36,6 +38,7 @@ #include "mongo/db/s/collection_sharding_state.h" #include "mongo/db/s/database_sharding_state.h" #include "mongo/db/views/view_catalog.h" +#include "mongo/logv2/log.h" #include "mongo/util/fail_point.h" namespace mongo { @@ -279,6 +282,30 @@ AutoGetCollectionLockFree::AutoGetCollectionLockFree(OperationContext* opCtx, !_view || viewMode == AutoGetCollectionViewMode::kViewsPermitted); } +AutoGetCollectionMaybeLockFree::AutoGetCollectionMaybeLockFree( + OperationContext* opCtx, + const NamespaceStringOrUUID& nsOrUUID, + LockMode modeColl, + AutoGetCollectionViewMode viewMode, + Date_t deadline) { + if (opCtx->isLockFreeReadsOp()) { + _autoGetLockFree.emplace(opCtx, + nsOrUUID, + [](std::shared_ptr<const Collection>& collection, + OperationContext* opCtx, + CollectionUUID uuid) { + LOGV2_FATAL( + 5342700, + "This is a nested lock helper and there was an attempt to " + "yield locks, which should be impossible"); + }, + viewMode, + deadline); + } else { + _autoGet.emplace(opCtx, nsOrUUID, modeColl, viewMode, deadline); + } +} + struct CollectionWriter::SharedImpl { SharedImpl(CollectionWriter* parent) : _parent(parent) {} |