summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorGeert Bosch <geert@mongodb.com>2016-12-08 15:58:23 -0500
committerGeert Bosch <geert@mongodb.com>2016-12-12 18:09:50 -0500
commit6dc9fc6ba93b62830dd905f6fac39e0802566a9a (patch)
tree9f95655578a9e49f70bc4d4ce13d975b0e014d8e /src/mongo/db
parent4ae06d14a14f520f8d16228670ab2e1836173dbc (diff)
downloadmongo-6dc9fc6ba93b62830dd905f6fac39e0802566a9a.tar.gz
SERVER-26126 Remove broken LockState caching
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/concurrency/lock_state.cpp19
-rw-r--r--src/mongo/db/concurrency/lock_state.h2
-rw-r--r--src/mongo/db/concurrency/locker.h7
-rw-r--r--src/mongo/db/concurrency/locker_noop.h4
-rw-r--r--src/mongo/db/operation_context.cpp5
-rw-r--r--src/mongo/db/operation_context.h6
-rw-r--r--src/mongo/db/operation_context_impl.cpp23
-rw-r--r--src/mongo/db/operation_context_impl.h2
-rw-r--r--src/mongo/db/repl/service_context_repl_mock.cpp1
9 files changed, 8 insertions, 61 deletions
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
@@ -191,17 +191,6 @@ bool LockerImpl<IsForMMAPV1>::isReadLocked() const {
}
template <bool IsForMMAPV1>
-void LockerImpl<IsForMMAPV1>::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 <bool IsForMMAPV1>
void LockerImpl<IsForMMAPV1>::dump() const {
StringBuilder ss;
ss << "Locker id " << _id << " status: ";
@@ -283,7 +272,13 @@ LockerImpl<IsForMMAPV1>::~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 <bool IsForMMAPV1>
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
@@ -309,13 +309,6 @@ public:
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<Locker> OperationContext::releaseLockState() {
- dassert(_locker);
- return std::move(_locker);
-}
-
void OperationContext::setLockState(std::unique_ptr<Locker> 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
@@ -123,12 +123,6 @@ public:
void setLockState(std::unique_ptr<Locker> locker);
/**
- * Releases the locker to the caller. Call during OperationContext cleanup or initialization,
- * only.
- */
- std::unique_ptr<Locker> releaseLockState();
-
- /**
* Raises a UserException if this operation is in a killed state.
*/
void checkForInterrupt();
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<Locker> newLocker() {
return stdx::make_unique<MMAPV1LockerImpl>();
return stdx::make_unique<DefaultLockerImpl>();
}
-
-class ClientOperationInfo {
-public:
- std::unique_ptr<Locker>& locker() {
- if (!_locker) {
- _locker = newLocker();
- }
- return _locker;
- }
-
-private:
- std::unique_ptr<Locker> _locker;
-};
-
-const auto clientOperationInfoDecoration = Client::declareDecoration<ClientOperationInfo>();
-
} // 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<OperationContext> ServiceContextReplMock::_newOpCtx(Client* client, unsigned opId) {
auto opCtx = stdx::make_unique<OperationContextNoop>(client, opId);
- opCtx->releaseLockState();
opCtx->setLockState(stdx::make_unique<MMAPV1LockerImpl>());
return std::move(opCtx);
}