diff options
Diffstat (limited to 'src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp')
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp index 556a01a2efb..87a0fa73e0f 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp @@ -187,7 +187,7 @@ public: while (!_shuttingDown.load()) { { - stdx::unique_lock<stdx::mutex> lock(_mutex); + stdx::unique_lock<Latch> lock(_mutex); MONGO_IDLE_THREAD_BLOCK; // Check every 10 seconds or sooner in the debug builds _condvar.wait_for(lock, stdx::chrono::seconds(kDebugBuild ? 1 : 10)); @@ -202,7 +202,7 @@ public: void shutdown() { _shuttingDown.store(true); { - stdx::unique_lock<stdx::mutex> lock(_mutex); + stdx::unique_lock<Latch> lock(_mutex); // Wake up the session sweeper thread early, we do not want the shutdown // to wait for us too long. _condvar.notify_one(); @@ -214,7 +214,7 @@ private: WiredTigerSessionCache* _sessionCache; AtomicWord<bool> _shuttingDown{false}; - stdx::mutex _mutex; // protects _condvar + Mutex _mutex = MONGO_MAKE_LATCH("WiredTigerSessionSweeper::_mutex"); // protects _condvar // The session sweeper thread idles on this condition variable for a particular time duration // between cleaning up expired sessions. It can be triggered early to expediate shutdown. stdx::condition_variable _condvar; @@ -322,7 +322,7 @@ public: auto opCtx = tc->makeOperationContext(); { - stdx::unique_lock<stdx::mutex> lock(_mutex); + stdx::unique_lock<Latch> lock(_mutex); MONGO_IDLE_THREAD_BLOCK; _condvar.wait_for(lock, stdx::chrono::seconds(static_cast<std::int64_t>( @@ -395,7 +395,7 @@ public: if (oplogNeededForRollback.isOK()) { // Now that the checkpoint is durable, publish the oplog needed to recover // from it. - stdx::lock_guard<stdx::mutex> lk(_oplogNeededForCrashRecoveryMutex); + stdx::lock_guard<Latch> lk(_oplogNeededForCrashRecoveryMutex); _oplogNeededForCrashRecovery.store( oplogNeededForRollback.getValue().asULL()); } @@ -440,7 +440,7 @@ public: _hasTriggeredFirstStableCheckpoint = true; log() << "Triggering the first stable checkpoint. Initial Data: " << initialData << " PrevStable: " << prevStable << " CurrStable: " << currStable; - stdx::unique_lock<stdx::mutex> lock(_mutex); + stdx::unique_lock<Latch> lock(_mutex); _condvar.notify_one(); } } @@ -454,14 +454,14 @@ public: * _oplogNeededForCrashRecovery will not change during assignment. */ void assignOplogNeededForCrashRecoveryTo(boost::optional<Timestamp>* timestamp) { - stdx::lock_guard<stdx::mutex> lk(_oplogNeededForCrashRecoveryMutex); + stdx::lock_guard<Latch> lk(_oplogNeededForCrashRecoveryMutex); *timestamp = Timestamp(_oplogNeededForCrashRecovery.load()); } void shutdown() { _shuttingDown.store(true); { - stdx::unique_lock<stdx::mutex> lock(_mutex); + stdx::unique_lock<Latch> lock(_mutex); // Wake up the checkpoint thread early, to take a final checkpoint before shutting // down, if one has not coincidentally just been taken. _condvar.notify_one(); @@ -473,7 +473,8 @@ private: WiredTigerKVEngine* _wiredTigerKVEngine; WiredTigerSessionCache* _sessionCache; - stdx::mutex _mutex; // protects _condvar + Mutex _mutex = MONGO_MAKE_LATCH("WiredTigerCheckpointThread::_mutex"); + ; // protects _condvar // The checkpoint thread idles on this condition variable for a particular time duration between // taking checkpoints. It can be triggered early to expediate immediate checkpointing. stdx::condition_variable _condvar; @@ -482,7 +483,8 @@ private: bool _hasTriggeredFirstStableCheckpoint = false; - stdx::mutex _oplogNeededForCrashRecoveryMutex; + Mutex _oplogNeededForCrashRecoveryMutex = + MONGO_MAKE_LATCH("WiredTigerCheckpointThread::_oplogNeededForCrashRecoveryMutex"); AtomicWord<std::uint64_t> _oplogNeededForCrashRecovery; }; @@ -1064,7 +1066,7 @@ StatusWith<std::vector<std::string>> WiredTigerKVEngine::beginNonBlockingBackup( uassert(51034, "Cannot open backup cursor with in-memory mode.", !isEphemeral()); // Oplog truncation thread won't remove oplog since the checkpoint pinned by the backup cursor. - stdx::lock_guard<stdx::mutex> lock(_oplogPinnedByBackupMutex); + stdx::lock_guard<Latch> lock(_oplogPinnedByBackupMutex); _checkpointThread->assignOplogNeededForCrashRecoveryTo(&_oplogPinnedByBackup); auto pinOplogGuard = makeGuard([&] { _oplogPinnedByBackup = boost::none; }); @@ -1099,7 +1101,7 @@ StatusWith<std::vector<std::string>> WiredTigerKVEngine::beginNonBlockingBackup( void WiredTigerKVEngine::endNonBlockingBackup(OperationContext* opCtx) { _backupSession.reset(); // Oplog truncation thread can now remove the pinned oplog. - stdx::lock_guard<stdx::mutex> lock(_oplogPinnedByBackupMutex); + stdx::lock_guard<Latch> lock(_oplogPinnedByBackupMutex); _oplogPinnedByBackup = boost::none; _backupCursor = nullptr; } @@ -1140,7 +1142,7 @@ void WiredTigerKVEngine::syncSizeInfo(bool sync) const { void WiredTigerKVEngine::setOldestActiveTransactionTimestampCallback( StorageEngine::OldestActiveTransactionTimestampCallback callback) { - stdx::lock_guard<stdx::mutex> lk(_oldestActiveTransactionTimestampCallbackMutex); + stdx::lock_guard<Latch> lk(_oldestActiveTransactionTimestampCallbackMutex); _oldestActiveTransactionTimestampCallback = std::move(callback); }; @@ -1403,7 +1405,7 @@ Status WiredTigerKVEngine::dropIdent(OperationContext* opCtx, StringData ident) if (ret == EBUSY) { // this is expected, queue it up { - stdx::lock_guard<stdx::mutex> lk(_identToDropMutex); + stdx::lock_guard<Latch> lk(_identToDropMutex); _identToDrop.push_front(uri); } _sessionCache->closeCursorsForQueuedDrops(); @@ -1422,7 +1424,7 @@ std::list<WiredTigerCachedCursor> WiredTigerKVEngine::filterCursorsWithQueuedDro std::list<WiredTigerCachedCursor>* cache) { std::list<WiredTigerCachedCursor> toDrop; - stdx::lock_guard<stdx::mutex> lk(_identToDropMutex); + stdx::lock_guard<Latch> lk(_identToDropMutex); if (_identToDrop.empty()) return toDrop; @@ -1456,7 +1458,7 @@ bool WiredTigerKVEngine::haveDropsQueued() const { _previousCheckedDropsQueued = now; // Don't wait for the mutex: if we can't get it, report that no drops are queued. - stdx::unique_lock<stdx::mutex> lk(_identToDropMutex, stdx::defer_lock); + stdx::unique_lock<Latch> lk(_identToDropMutex, stdx::defer_lock); return lk.try_lock() && !_identToDrop.empty(); } @@ -1466,7 +1468,7 @@ void WiredTigerKVEngine::dropSomeQueuedIdents() { WiredTigerSession session(_conn); { - stdx::lock_guard<stdx::mutex> lk(_identToDropMutex); + stdx::lock_guard<Latch> lk(_identToDropMutex); numInQueue = _identToDrop.size(); } @@ -1479,7 +1481,7 @@ void WiredTigerKVEngine::dropSomeQueuedIdents() { for (int i = 0; i < numToDelete; i++) { string uri; { - stdx::lock_guard<stdx::mutex> lk(_identToDropMutex); + stdx::lock_guard<Latch> lk(_identToDropMutex); if (_identToDrop.empty()) break; uri = _identToDrop.front(); @@ -1490,7 +1492,7 @@ void WiredTigerKVEngine::dropSomeQueuedIdents() { LOG(1) << "WT queued drop of " << uri << " res " << ret; if (ret == EBUSY) { - stdx::lock_guard<stdx::mutex> lk(_identToDropMutex); + stdx::lock_guard<Latch> lk(_identToDropMutex); _identToDrop.push_back(uri); } else { invariantWTOK(ret); @@ -1871,7 +1873,7 @@ StatusWith<Timestamp> WiredTigerKVEngine::getOplogNeededForRollback() const { auto stableTimestamp = _stableTimestamp.load(); // Only one thread can set or execute this callback. - stdx::lock_guard<stdx::mutex> lk(_oldestActiveTransactionTimestampCallbackMutex); + stdx::lock_guard<Latch> lk(_oldestActiveTransactionTimestampCallbackMutex); boost::optional<Timestamp> oldestActiveTransactionTimestamp; if (_oldestActiveTransactionTimestampCallback) { auto status = _oldestActiveTransactionTimestampCallback(Timestamp(stableTimestamp)); @@ -1904,7 +1906,7 @@ boost::optional<Timestamp> WiredTigerKVEngine::getOplogNeededForCrashRecovery() Timestamp WiredTigerKVEngine::getPinnedOplog() const { { - stdx::lock_guard<stdx::mutex> lock(_oplogPinnedByBackupMutex); + stdx::lock_guard<Latch> lock(_oplogPinnedByBackupMutex); if (!storageGlobalParams.allowOplogTruncation) { // If oplog truncation is not allowed, then return the min timestamp so that no history // is @@ -1956,14 +1958,14 @@ bool WiredTigerKVEngine::supportsOplogStones() const { void WiredTigerKVEngine::startOplogManager(OperationContext* opCtx, const std::string& uri, WiredTigerRecordStore* oplogRecordStore) { - stdx::lock_guard<stdx::mutex> lock(_oplogManagerMutex); + stdx::lock_guard<Latch> lock(_oplogManagerMutex); if (_oplogManagerCount == 0) _oplogManager->start(opCtx, uri, oplogRecordStore); _oplogManagerCount++; } void WiredTigerKVEngine::haltOplogManager() { - stdx::unique_lock<stdx::mutex> lock(_oplogManagerMutex); + stdx::unique_lock<Latch> lock(_oplogManagerMutex); invariant(_oplogManagerCount > 0); _oplogManagerCount--; if (_oplogManagerCount == 0) { |