Skip to content

Commit

Permalink
SERVER-32397: Notify waiters on any movement of the oplog read timest…
Browse files Browse the repository at this point in the history
…amp.
  • Loading branch information
Daniel Gottlieb committed Dec 20, 2017
1 parent 7a1b4d8 commit 0b79766
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,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 */);
Expand Down Expand Up @@ -187,10 +187,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.
Expand All @@ -209,11 +207,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;
}

Expand Down
3 changes: 2 additions & 1 deletion src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -83,7 +84,7 @@ class WiredTigerOplogManager {
WiredTigerRecordStore* oplogRecordStore,
bool isMasterSlave) noexcept;

void _setOplogReadTimestamp(uint64_t newTimestamp);
void _setOplogReadTimestamp(WithLock, uint64_t newTimestamp);

uint64_t _fetchAllCommittedValue(WT_CONNECTION* conn);

Expand Down

0 comments on commit 0b79766

Please sign in to comment.