summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gottlieb <daniel.gottlieb@mongodb.com>2017-12-20 08:55:41 -0500
committerDaniel Gottlieb <daniel.gottlieb@mongodb.com>2017-12-20 16:22:51 -0500
commit025d4f4fe61efd1fb6f0005be20cb45a004093d1 (patch)
tree6e46123b5a042891f626bf144bef39e1c2ef619a
parent4882a14ef69e456760da9ee4774ad6c5edf2d474 (diff)
downloadmongo-025d4f4fe61efd1fb6f0005be20cb45a004093d1.tar.gz
SERVER-32397: Notify waiters on any movement of the oplog read timestamp.r3.6.1-rc1r3.6.1
(cherry picked from commit 0b7976614d028105a203147fe571b3c264e920b3)
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.cpp12
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h3
2 files changed, 8 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 65a57b54c27..95a6b14e1ef 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.cpp
@@ -54,7 +54,7 @@ void WiredTigerOplogManager::start(OperationContext* opCtx,
invariant(!_isRunning);
// Prime the oplog read timestamp.
auto sessionCache = WiredTigerRecoveryUnit::get(opCtx)->getSessionCache();
- _setOplogReadTimestamp(_fetchAllCommittedValue(sessionCache->conn()));
+ setOplogReadTimestamp(Timestamp(_fetchAllCommittedValue(sessionCache->conn())));
std::unique_ptr<SeekableRecordCursor> reverseOplogCursor =
oplogRecordStore->getCursor(opCtx, false /* false = reverse cursor */);
@@ -189,10 +189,8 @@ void WiredTigerOplogManager::_oplogJournalThreadLoop(WiredTigerSessionCache* ses
sessionCache->waitUntilDurable(/*forceCheckpoint=*/false, false);
lk.lock();
-
// Publish the new timestamp value.
- _setOplogReadTimestamp(newTimestamp);
- _opsBecameVisibleCV.notify_all();
+ _setOplogReadTimestamp(lk, newTimestamp);
lk.unlock();
// Wake up any await_data cursors and tell them more data might be visible now.
@@ -212,11 +210,13 @@ std::uint64_t WiredTigerOplogManager::getOplogReadTimestamp() const {
}
void WiredTigerOplogManager::setOplogReadTimestamp(Timestamp ts) {
- _oplogReadTimestamp.store(ts.asULL());
+ stdx::lock_guard<stdx::mutex> lk(_oplogVisibilityStateMutex);
+ _setOplogReadTimestamp(lk, ts.asULL());
}
-void WiredTigerOplogManager::_setOplogReadTimestamp(uint64_t newTimestamp) {
+void WiredTigerOplogManager::_setOplogReadTimestamp(WithLock, uint64_t newTimestamp) {
_oplogReadTimestamp.store(newTimestamp);
+ _opsBecameVisibleCV.notify_all();
LOG(2) << "setting new oplogReadTimestamp: " << newTimestamp;
}
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h b/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h
index 0ed0b7d0d4a..48c4cf0e5bd 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h
@@ -35,6 +35,7 @@
#include "mongo/stdx/condition_variable.h"
#include "mongo/stdx/mutex.h"
#include "mongo/stdx/thread.h"
+#include "mongo/util/concurrency/with_lock.h"
namespace mongo {
@@ -85,7 +86,7 @@ private:
WiredTigerRecordStore* oplogRecordStore,
bool isMasterSlave) noexcept;
- void _setOplogReadTimestamp(uint64_t newTimestamp);
+ void _setOplogReadTimestamp(WithLock, uint64_t newTimestamp);
uint64_t _fetchAllCommittedValue(WT_CONNECTION* conn);