diff options
author | Esha Maharishi <esha.maharishi@mongodb.com> | 2016-12-13 11:07:14 -0500 |
---|---|---|
committer | Esha Maharishi <esha.maharishi@mongodb.com> | 2016-12-13 11:07:14 -0500 |
commit | 4061adae4c4cc556954ae50924f4aadd9f8ac732 (patch) | |
tree | 90e8bd1fcd75afd36f4f4d31d9344a3917e6b44c /src/mongo/db/concurrency | |
parent | 7678cba70d790eab3eb546988c77bb34ab83da1a (diff) | |
download | mongo-4061adae4c4cc556954ae50924f4aadd9f8ac732.tar.gz |
Revert "SERVER-26126 Remove broken LockState caching"
This reverts commit 6dc9fc6ba93b62830dd905f6fac39e0802566a9a.
Diffstat (limited to 'src/mongo/db/concurrency')
-rw-r--r-- | src/mongo/db/concurrency/lock_state.cpp | 19 | ||||
-rw-r--r-- | src/mongo/db/concurrency/lock_state.h | 2 | ||||
-rw-r--r-- | src/mongo/db/concurrency/locker.h | 7 | ||||
-rw-r--r-- | src/mongo/db/concurrency/locker_noop.h | 4 |
4 files changed, 25 insertions, 7 deletions
diff --git a/src/mongo/db/concurrency/lock_state.cpp b/src/mongo/db/concurrency/lock_state.cpp index 9235f56bbb4..898f9cd462e 100644 --- a/src/mongo/db/concurrency/lock_state.cpp +++ b/src/mongo/db/concurrency/lock_state.cpp @@ -191,6 +191,17 @@ 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: "; @@ -272,13 +283,7 @@ 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. - invariant(!inAWriteUnitOfWork()); - invariant(_resourcesToUnlockAtEndOfUnitOfWork.empty()); - invariant(_requests.empty()); - invariant(_modeForTicket == MODE_NONE); - - // Reset the locking statistics so the object can be reused - _stats.reset(); + assertEmptyAndReset(); } template <bool IsForMMAPV1> diff --git a/src/mongo/db/concurrency/lock_state.h b/src/mongo/db/concurrency/lock_state.h index e4bdded0bdf..79f348d4ac6 100644 --- a/src/mongo/db/concurrency/lock_state.h +++ b/src/mongo/db/concurrency/lock_state.h @@ -244,6 +244,8 @@ 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 6dacd299e65..e00882a498d 100644 --- a/src/mongo/db/concurrency/locker.h +++ b/src/mongo/db/concurrency/locker.h @@ -309,6 +309,13 @@ 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 ff252243964..24450ceeecc 100644 --- a/src/mongo/db/concurrency/locker_noop.h +++ b/src/mongo/db/concurrency/locker_noop.h @@ -160,6 +160,10 @@ public: invariant(false); } + virtual void assertEmptyAndReset() { + invariant(false); + } + virtual bool hasLockPending() const { invariant(false); } |