diff options
author | Suganthi Mani <suganthi.mani@mongodb.com> | 2019-01-15 06:41:23 -0500 |
---|---|---|
committer | Suganthi Mani <suganthi.mani@mongodb.com> | 2019-01-23 09:05:58 -0500 |
commit | 55d6072f0be597e950809d9ebcf9ba16cc96942d (patch) | |
tree | 46beb62563e7a2c4ef9b704123c4a540b820b5e3 /src/mongo/db/concurrency/global_lock_acquisition_tracker.h | |
parent | b89d1cb056f82af22a5bef211bd2680f3784e7c2 (diff) | |
download | mongo-55d6072f0be597e950809d9ebcf9ba16cc96942d.tar.gz |
SERVER-38511 Avoid killing read operations on stepdown, gated by new server parameter “closeConnectionsOnStepdown”.
Diffstat (limited to 'src/mongo/db/concurrency/global_lock_acquisition_tracker.h')
-rw-r--r-- | src/mongo/db/concurrency/global_lock_acquisition_tracker.h | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/mongo/db/concurrency/global_lock_acquisition_tracker.h b/src/mongo/db/concurrency/global_lock_acquisition_tracker.h index 1d83b280182..8c55a1c0ec0 100644 --- a/src/mongo/db/concurrency/global_lock_acquisition_tracker.h +++ b/src/mongo/db/concurrency/global_lock_acquisition_tracker.h @@ -35,9 +35,11 @@ namespace mongo { /** - * The GlobalLockAcquisitionTracker keeps track of if the global lock has ever been taken in X or - * IX mode. This class is used to track if we ever did a transaction with the intent to do a - * write, so that we can enforce write concern on noop writes. + * GlobalLockAcquisitionTracker keeps track of the global lock modes acquired during the + * operation's lifetime. This class is used to track if we ever did a transaction with the + * intent to do a write, so that we can enforce write concern on noop writes. Also, used + * during step down to kill all user operations except those that acquired global lock in + * IS mode. */ class GlobalLockAcquisitionTracker { public: @@ -49,16 +51,21 @@ public: /** * Returns whether we have ever taken a global lock in X or IX mode in this operation. */ - bool getGlobalExclusiveLockTaken() const; + bool getGlobalWriteLocked() const; /** - * Sets that we have ever taken a global lock in X or IX mode in this operation. + * Returns whether we have ever taken a global lock in S mode in this operation. */ - void setGlobalExclusiveLockTaken(); + bool getGlobalSharedLockTaken() const; + + /** + * Sets the mode bit in _globalLockMode. Once a mode bit is set, we won't clear it. + */ + void setGlobalLockModeBit(LockMode mode); private: - // Set to true when the global lock is first taken in X or IX mode. Never set back to false. - bool _globalExclusiveLockTaken = false; + // keeps track of the global lock modes acquired for this operation. + unsigned char _globalLockMode = (1 << MODE_NONE); }; } // namespace mongo |