summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDianna Hohensee <dianna.hohensee@mongodb.com>2020-05-15 11:56:19 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-05-15 19:09:47 +0000
commit26cff8f010cac091c17d7373f8ead0e8c73ee6f7 (patch)
tree165a75659fc47cc9bb823f5fcbffb2f615ee9698
parente9666e1a6f1494e181c0f064db92734d01206430 (diff)
downloadmongo-26cff8f010cac091c17d7373f8ead0e8c73ee6f7.tar.gz
SERVER-48240 Undo accidental functional change to WiredTigerOplogManager that causes a performance degradation
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.cpp18
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h9
2 files changed, 20 insertions, 7 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.cpp
index f0d05d9af75..72e0e2103a7 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.cpp
@@ -102,8 +102,8 @@ void WiredTigerOplogManager::haltVisibilityThread() {
void WiredTigerOplogManager::triggerOplogVisibilityUpdate() {
stdx::lock_guard<Latch> lk(_oplogVisibilityStateMutex);
- if (!_opsWaitingForOplogVisibility) {
- _opsWaitingForOplogVisibility = true;
+ if (!_triggerOplogVisibilityUpdate) {
+ _triggerOplogVisibilityUpdate = true;
_oplogVisibilityThreadCV.notify_one();
}
}
@@ -134,6 +134,12 @@ void WiredTigerOplogManager::waitForAllEarlierOplogWritesToBeVisible(
stdx::unique_lock<Latch> lk(_oplogVisibilityStateMutex);
+ // Prevent any scheduled oplog visibility updates from being delayed for batching and blocking
+ // this wait excessively.
+ ++_opsWaitingForOplogVisibilityUpdate;
+ invariant(_opsWaitingForOplogVisibilityUpdate > 0);
+ auto exitGuard = makeGuard([&] { --_opsWaitingForOplogVisibilityUpdate; });
+
// Out of order writes to the oplog always call triggerOplogVisibilityUpdate() on commit to
// prompt the OplogVisibilityThread to run and update the oplog visibility. We simply need to
// wait until all of the writes behind and including 'waitingFor' commit so there are no oplog
@@ -180,7 +186,7 @@ void WiredTigerOplogManager::_updateOplogVisibilityLoop(WiredTigerSessionCache*
{
MONGO_IDLE_THREAD_BLOCK;
_oplogVisibilityThreadCV.wait(
- lk, [&] { return _shuttingDown || _opsWaitingForOplogVisibility; });
+ lk, [&] { return _shuttingDown || _triggerOplogVisibilityUpdate; });
// If we are not shutting down and nobody is actively waiting for the oplog to become
// visible, delay a bit to batch more requests into one update and reduce system load.
@@ -188,7 +194,7 @@ void WiredTigerOplogManager::_updateOplogVisibilityLoop(WiredTigerSessionCache*
auto deadline = now + Milliseconds(kDelayMillis);
auto wakeUpEarlyForWaitersPredicate = [&] {
- return _shuttingDown || _opsWaitingForOplogVisibility ||
+ return _shuttingDown || _opsWaitingForOplogVisibilityUpdate ||
oplogRecordStore->haveCappedWaiters();
};
@@ -212,8 +218,8 @@ void WiredTigerOplogManager::_updateOplogVisibilityLoop(WiredTigerSessionCache*
return;
}
- invariant(_opsWaitingForOplogVisibility);
- _opsWaitingForOplogVisibility = false;
+ invariant(_triggerOplogVisibilityUpdate);
+ _triggerOplogVisibilityUpdate = false;
lk.unlock();
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h b/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h
index e9428bbd772..011876efd3e 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h
@@ -134,6 +134,13 @@ private:
bool _isRunning = false;
bool _shuttingDown = false;
- bool _opsWaitingForOplogVisibility = false;
+
+ // Triggers an oplog visibility update -- can be delayed if no callers are waiting for an
+ // update, per the _opsWaitingForOplogVisibility counter.
+ bool _triggerOplogVisibilityUpdate = false;
+
+ // Incremented when a caller is waiting for more of the oplog to become visible, to avoid update
+ // delays for batching.
+ int64_t _opsWaitingForOplogVisibilityUpdate = 0;
};
} // namespace mongo