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.

(cherry picked from commit 0b79766)
  • Loading branch information
Daniel Gottlieb committed Dec 20, 2017
1 parent 4882a14 commit 025d4f4
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
Expand Up @@ -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 */);
Expand Down Expand Up @@ -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.
Expand All @@ -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;
}

Expand Down
3 changes: 2 additions & 1 deletion src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h
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 @@ -85,7 +86,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 025d4f4

Please sign in to comment.