summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2017-01-10 12:05:30 -0500
committerBenety Goh <benety@mongodb.com>2017-01-18 14:33:47 -0500
commit3b126d3ebe606f1ab13a178a4c22e797caafe12c (patch)
tree48f1c56941b87b081d08b6a8097d28ceb6362b4e
parent4846d18d25916a1dd5b8ddffc7942bc32501c952 (diff)
downloadmongo-3b126d3ebe606f1ab13a178a4c22e797caafe12c.tar.gz
SERVER-27624 SyncSourceFeedback should check for shutdown before setting _reporter
(cherry picked from commit 2264c7411e119e6c3c8198f6c31f641e65b9f3cb)
-rw-r--r--src/mongo/db/repl/sync_source_feedback.cpp15
-rw-r--r--src/mongo/db/repl/sync_source_feedback.h2
2 files changed, 8 insertions, 9 deletions
diff --git a/src/mongo/db/repl/sync_source_feedback.cpp b/src/mongo/db/repl/sync_source_feedback.cpp
index 96ac055f792..c384fe6cf9b 100644
--- a/src/mongo/db/repl/sync_source_feedback.cpp
+++ b/src/mongo/db/repl/sync_source_feedback.cpp
@@ -114,13 +114,9 @@ void SyncSourceFeedback::forwardSlaveProgress() {
}
}
-Status SyncSourceFeedback::_updateUpstream(OperationContext* txn, BackgroundSync* bgsync) {
- Reporter* reporter;
- {
- stdx::lock_guard<stdx::mutex> lock(_mtx);
- reporter = _reporter;
- }
-
+Status SyncSourceFeedback::_updateUpstream(OperationContext* txn,
+ BackgroundSync* bgsync,
+ Reporter* reporter) {
auto syncTarget = reporter->getTarget();
auto triggerStatus = reporter->trigger();
@@ -240,6 +236,9 @@ void SyncSourceFeedback::run(executor::TaskExecutor* executor, BackgroundSync* b
keepAliveInterval);
{
stdx::lock_guard<stdx::mutex> lock(_mtx);
+ if (_shutdownSignaled) {
+ break;
+ }
_reporter = &reporter;
}
ON_BLOCK_EXIT([this]() {
@@ -247,7 +246,7 @@ void SyncSourceFeedback::run(executor::TaskExecutor* executor, BackgroundSync* b
_reporter = nullptr;
});
- auto status = _updateUpstream(txn.get(), bgsync);
+ auto status = _updateUpstream(txn.get(), bgsync, &reporter);
if (!status.isOK()) {
LOG(1) << "The replication progress command (replSetUpdatePosition) failed and will be "
"retried: "
diff --git a/src/mongo/db/repl/sync_source_feedback.h b/src/mongo/db/repl/sync_source_feedback.h
index c8f20b614be..40c29dc172a 100644
--- a/src/mongo/db/repl/sync_source_feedback.h
+++ b/src/mongo/db/repl/sync_source_feedback.h
@@ -72,7 +72,7 @@ private:
/* Inform the sync target of our current position in the oplog, as well as the positions
* of all secondaries chained through us.
*/
- Status _updateUpstream(OperationContext* txn, BackgroundSync* bgsync);
+ Status _updateUpstream(OperationContext* txn, BackgroundSync* bgsync, Reporter* reporter);
// protects cond, _shutdownSignaled, _keepAliveInterval, and _positionChanged.
stdx::mutex _mtx;