diff options
author | Bruce Lucas <bruce.lucas@mongodb.com> | 2018-01-31 09:23:19 -0500 |
---|---|---|
committer | Bruce Lucas <bruce.lucas@mongodb.com> | 2018-01-31 09:23:19 -0500 |
commit | 4fa890fa8b6ba3b438213efcfab07b588fd58e63 (patch) | |
tree | f0e05c2c4979a247bc109fcbbd406f63f09fa686 | |
parent | 757c3e7f0d0819c98c9e3d9eff17c520886891e6 (diff) | |
download | mongo-4fa890fa8b6ba3b438213efcfab07b588fd58e63.tar.gz |
SERVER-32875 Don't stall ftdc due to running out of tickets
-rw-r--r-- | src/mongo/db/concurrency/lock_state.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/concurrency/locker.h | 13 | ||||
-rw-r--r-- | src/mongo/db/ftdc/collector.cpp | 1 |
3 files changed, 15 insertions, 1 deletions
diff --git a/src/mongo/db/concurrency/lock_state.cpp b/src/mongo/db/concurrency/lock_state.cpp index bf48ec3ba51..c1d02193129 100644 --- a/src/mongo/db/concurrency/lock_state.cpp +++ b/src/mongo/db/concurrency/lock_state.cpp @@ -311,7 +311,7 @@ LockResult LockerImpl<IsForMMAPV1>::_lockGlobalBegin(LockMode mode, Milliseconds dassert(isLocked() == (_modeForTicket != MODE_NONE)); if (_modeForTicket == MODE_NONE) { const bool reader = isSharedLockMode(mode); - auto holder = ticketHolders[mode]; + auto holder = shouldAcquireTicket() ? ticketHolders[mode] : nullptr; if (holder) { _clientState.store(reader ? kQueuedReader : kQueuedWriter); if (timeout == Milliseconds::max()) { diff --git a/src/mongo/db/concurrency/locker.h b/src/mongo/db/concurrency/locker.h index 37af569124f..10466e143b4 100644 --- a/src/mongo/db/concurrency/locker.h +++ b/src/mongo/db/concurrency/locker.h @@ -334,11 +334,24 @@ public: return _shouldConflictWithSecondaryBatchApplication; } + /** + * If set to false, this opts out of the ticket mechanism. This should be used sparingly + * for special purpose threads, such as FTDC. + */ + void setShouldAcquireTicket(bool newValue) { + _shouldAcquireTicket = newValue; + } + bool shouldAcquireTicket() const { + return _shouldAcquireTicket; + } + + protected: Locker() {} private: bool _shouldConflictWithSecondaryBatchApplication = true; + bool _shouldAcquireTicket = true; }; } // namespace mongo diff --git a/src/mongo/db/ftdc/collector.cpp b/src/mongo/db/ftdc/collector.cpp index 611f12dff5a..7c35fb12bb6 100644 --- a/src/mongo/db/ftdc/collector.cpp +++ b/src/mongo/db/ftdc/collector.cpp @@ -67,6 +67,7 @@ std::tuple<BSONObj, Date_t> FTDCCollectorCollection::collect(Client* client) { // batches that are taking a long time. auto txn = client->makeOperationContext(); txn->lockState()->setShouldConflictWithSecondaryBatchApplication(false); + txn->lockState()->setShouldAcquireTicket(false); for (auto& collector : _collectors) { BSONObjBuilder subObjBuilder(builder.subobjStart(collector->name())); |