diff options
author | Siyuan Zhou <siyuan.zhou@mongodb.com> | 2018-07-12 00:52:31 -0400 |
---|---|---|
committer | Siyuan Zhou <siyuan.zhou@mongodb.com> | 2018-07-13 14:42:20 -0400 |
commit | 97f15caddf7835ef5ed252257903edc52dae9aaf (patch) | |
tree | d9d0bc32e709ef6762d2ceb0b15e2c3e906c8c81 | |
parent | 4e95b7ca81265d3a12eb7f9ae3952dc50238b6e8 (diff) | |
download | mongo-97f15caddf7835ef5ed252257903edc52dae9aaf.tar.gz |
SERVER-33243 Improve logging when a node changes its sync source
-rw-r--r-- | src/mongo/db/repl/bgsync.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/mongo/db/repl/bgsync.cpp b/src/mongo/db/repl/bgsync.cpp index 216fb122553..aecbd399fc8 100644 --- a/src/mongo/db/repl/bgsync.cpp +++ b/src/mongo/db/repl/bgsync.cpp @@ -290,6 +290,9 @@ void BackgroundSync::_produce() { } const auto requiredOpTime = (minValidSaved > _lastOpTimeFetched) ? minValidSaved : OpTime(); lastOpTimeFetched = _lastOpTimeFetched; + if (!_syncSourceHost.empty()) { + log() << "Clearing sync source " << _syncSourceHost << " to choose a new one."; + } _syncSourceHost = HostAndPort(); _syncSourceResolver = stdx::make_unique<SyncSourceResolver>( _replicationCoordinatorExternalState->getTaskExecutor(), @@ -368,6 +371,10 @@ void BackgroundSync::_produce() { << ". Sleeping for 1 second to avoid immediately choosing a new sync source for " "the same reason as last time."; sleepsecs(1); + } else { + log() << "Changed sync source from " + << (oldSource.empty() ? std::string("empty") : oldSource.toString()) << " to " + << source; } } else { if (!syncSourceResp.isOK()) { @@ -385,7 +392,7 @@ void BackgroundSync::_produce() { _tooStale = false; - log() << "No longer too stale. Able to sync from " << _syncSourceHost; + log() << "No longer too stale. Able to sync from " << source; auto status = _replCoord->setMaintenanceMode(false); if (!status.isOK()) { @@ -455,8 +462,8 @@ void BackgroundSync::_produce() { } const auto logLevel = getTestCommandsEnabled() ? 0 : 1; - LOG(logLevel) << "scheduling fetcher to read remote oplog on " << _syncSourceHost - << " starting at " << oplogFetcher->getFindQuery_forTest()["filter"]; + LOG(logLevel) << "scheduling fetcher to read remote oplog on " << source << " starting at " + << oplogFetcher->getFindQuery_forTest()["filter"]; auto scheduleStatus = oplogFetcher->startup(); if (!scheduleStatus.isOK()) { warning() << "unable to schedule fetcher to read remote oplog on " << source << ": " @@ -689,6 +696,7 @@ HostAndPort BackgroundSync::getSyncTarget() const { void BackgroundSync::clearSyncTarget() { stdx::unique_lock<stdx::mutex> lock(_mutex); + log() << "Resetting sync source to empty, which was " << _syncSourceHost; _syncSourceHost = HostAndPort(); } |