From 6dc9fc6ba93b62830dd905f6fac39e0802566a9a Mon Sep 17 00:00:00 2001 From: Geert Bosch Date: Thu, 8 Dec 2016 15:58:23 -0500 Subject: SERVER-26126 Remove broken LockState caching --- src/mongo/db/concurrency/lock_state.cpp | 19 +++++++------------ src/mongo/db/concurrency/lock_state.h | 2 -- src/mongo/db/concurrency/locker.h | 7 ------- src/mongo/db/concurrency/locker_noop.h | 4 ---- src/mongo/db/operation_context.cpp | 5 ----- src/mongo/db/operation_context.h | 6 ------ src/mongo/db/operation_context_impl.cpp | 23 +---------------------- src/mongo/db/operation_context_impl.h | 2 -- src/mongo/db/repl/service_context_repl_mock.cpp | 1 - 9 files changed, 8 insertions(+), 61 deletions(-) (limited to 'src/mongo/db') diff --git a/src/mongo/db/concurrency/lock_state.cpp b/src/mongo/db/concurrency/lock_state.cpp index 898f9cd462e..9235f56bbb4 100644 --- a/src/mongo/db/concurrency/lock_state.cpp +++ b/src/mongo/db/concurrency/lock_state.cpp @@ -190,17 +190,6 @@ bool LockerImpl::isReadLocked() const { return isLockHeldForMode(resourceIdGlobal, MODE_IS); } -template -void LockerImpl::assertEmptyAndReset() { - invariant(!inAWriteUnitOfWork()); - invariant(_resourcesToUnlockAtEndOfUnitOfWork.empty()); - invariant(_requests.empty()); - invariant(_modeForTicket == MODE_NONE); - - // Reset the locking statistics so the object can be reused - _stats.reset(); -} - template void LockerImpl::dump() const { StringBuilder ss; @@ -283,7 +272,13 @@ LockerImpl::~LockerImpl() { // Cannot delete the Locker while there are still outstanding requests, because the // LockManager may attempt to access deleted memory. Besides it is probably incorrect // to delete with unaccounted locks anyways. - assertEmptyAndReset(); + invariant(!inAWriteUnitOfWork()); + invariant(_resourcesToUnlockAtEndOfUnitOfWork.empty()); + invariant(_requests.empty()); + invariant(_modeForTicket == MODE_NONE); + + // Reset the locking statistics so the object can be reused + _stats.reset(); } template diff --git a/src/mongo/db/concurrency/lock_state.h b/src/mongo/db/concurrency/lock_state.h index 79f348d4ac6..e4bdded0bdf 100644 --- a/src/mongo/db/concurrency/lock_state.h +++ b/src/mongo/db/concurrency/lock_state.h @@ -244,8 +244,6 @@ public: virtual bool isWriteLocked() const; virtual bool isReadLocked() const; - virtual void assertEmptyAndReset(); - virtual bool hasLockPending() const { return getWaitingResource().isValid(); } diff --git a/src/mongo/db/concurrency/locker.h b/src/mongo/db/concurrency/locker.h index e00882a498d..6dacd299e65 100644 --- a/src/mongo/db/concurrency/locker.h +++ b/src/mongo/db/concurrency/locker.h @@ -308,13 +308,6 @@ public: virtual bool isWriteLocked() const = 0; virtual bool isReadLocked() const = 0; - /** - * Asserts that the Locker is effectively not in use and resets the locking statistics. - * This means, there should be no locks on it, no WUOW, etc, so it would be safe to call - * the destructor or reuse the Locker. - */ - virtual void assertEmptyAndReset() = 0; - /** * Pending means we are currently trying to get a lock (could be the parallel batch writer * lock). diff --git a/src/mongo/db/concurrency/locker_noop.h b/src/mongo/db/concurrency/locker_noop.h index 24450ceeecc..ff252243964 100644 --- a/src/mongo/db/concurrency/locker_noop.h +++ b/src/mongo/db/concurrency/locker_noop.h @@ -160,10 +160,6 @@ public: invariant(false); } - virtual void assertEmptyAndReset() { - invariant(false); - } - virtual bool hasLockPending() const { invariant(false); } diff --git a/src/mongo/db/operation_context.cpp b/src/mongo/db/operation_context.cpp index 8151fe97dfa..f96c644b431 100644 --- a/src/mongo/db/operation_context.cpp +++ b/src/mongo/db/operation_context.cpp @@ -397,11 +397,6 @@ OperationContext::RecoveryUnitState OperationContext::setRecoveryUnit(RecoveryUn return oldState; } -std::unique_ptr OperationContext::releaseLockState() { - dassert(_locker); - return std::move(_locker); -} - void OperationContext::setLockState(std::unique_ptr locker) { dassert(!_locker); dassert(locker); diff --git a/src/mongo/db/operation_context.h b/src/mongo/db/operation_context.h index 2c8be360a77..b9d57951ec1 100644 --- a/src/mongo/db/operation_context.h +++ b/src/mongo/db/operation_context.h @@ -122,12 +122,6 @@ public: */ void setLockState(std::unique_ptr locker); - /** - * Releases the locker to the caller. Call during OperationContext cleanup or initialization, - * only. - */ - std::unique_ptr releaseLockState(); - /** * Raises a UserException if this operation is in a killed state. */ diff --git a/src/mongo/db/operation_context_impl.cpp b/src/mongo/db/operation_context_impl.cpp index 7fae6cfa4a7..0ccdbbbfbef 100644 --- a/src/mongo/db/operation_context_impl.cpp +++ b/src/mongo/db/operation_context_impl.cpp @@ -47,38 +47,17 @@ std::unique_ptr newLocker() { return stdx::make_unique(); return stdx::make_unique(); } - -class ClientOperationInfo { -public: - std::unique_ptr& locker() { - if (!_locker) { - _locker = newLocker(); - } - return _locker; - } - -private: - std::unique_ptr _locker; -}; - -const auto clientOperationInfoDecoration = Client::declareDecoration(); - } // namespace using std::string; OperationContextImpl::OperationContextImpl(Client* client, unsigned opId) : OperationContext(client, opId) { - setLockState(std::move(clientOperationInfoDecoration(client).locker())); + setLockState(newLocker()); StorageEngine* storageEngine = getServiceContext()->getGlobalStorageEngine(); setRecoveryUnit(storageEngine->newRecoveryUnit(), kNotInUnitOfWork); } -OperationContextImpl::~OperationContextImpl() { - lockState()->assertEmptyAndReset(); - clientOperationInfoDecoration(getClient()).locker() = releaseLockState(); -} - ProgressMeter* OperationContextImpl::setMessage_inlock(const char* msg, const std::string& name, unsigned long long progressMeterTotal, diff --git a/src/mongo/db/operation_context_impl.h b/src/mongo/db/operation_context_impl.h index c6069f01e8b..bc23dcbb089 100644 --- a/src/mongo/db/operation_context_impl.h +++ b/src/mongo/db/operation_context_impl.h @@ -35,8 +35,6 @@ namespace mongo { class OperationContextImpl final : public OperationContext { public: - virtual ~OperationContextImpl(); - virtual ProgressMeter* setMessage_inlock(const char* msg, const std::string& name, unsigned long long progressMeterTotal, diff --git a/src/mongo/db/repl/service_context_repl_mock.cpp b/src/mongo/db/repl/service_context_repl_mock.cpp index ba88cf149bd..ac416a62156 100644 --- a/src/mongo/db/repl/service_context_repl_mock.cpp +++ b/src/mongo/db/repl/service_context_repl_mock.cpp @@ -42,7 +42,6 @@ namespace repl { std::unique_ptr ServiceContextReplMock::_newOpCtx(Client* client, unsigned opId) { auto opCtx = stdx::make_unique(client, opId); - opCtx->releaseLockState(); opCtx->setLockState(stdx::make_unique()); return std::move(opCtx); } -- cgit v1.2.1