diff options
author | Scott Hernandez <scotthernandez@gmail.com> | 2015-12-08 18:50:03 -0500 |
---|---|---|
committer | Scott Hernandez <scotthernandez@gmail.com> | 2015-12-14 12:36:56 -0500 |
commit | b7e9e964c6b3739f1a1703e7a165e0a197c3c676 (patch) | |
tree | b283de7ee50266f3163d67fa4931a2b110ee5a0a /src | |
parent | 335c1ce2d1a6344b1643414c9368b63a34598324 (diff) | |
download | mongo-b7e9e964c6b3739f1a1703e7a165e0a197c3c676.tar.gz |
SERVER-21795: Do not reschedule more than one liveness timeout callback at a time
(cherry picked from commit 5ab583935e048522d2129ab11f6c485a59dee7df)
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp | 7 | ||||
-rw-r--r-- | src/mongo/db/repl/replication_executor.cpp | 5 | ||||
-rw-r--r-- | src/mongo/db/repl/replication_executor.h | 4 |
3 files changed, 12 insertions, 4 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp b/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp index cfc8116e1b6..e7f9140eca6 100644 --- a/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp @@ -554,7 +554,12 @@ void ReplicationCoordinatorImpl::_startHeartbeats_inlock( void ReplicationCoordinatorImpl::_handleLivenessTimeout( const ReplicationExecutor::CallbackArgs& cbData) { stdx::lock_guard<stdx::mutex> lk(_mutex); - _handleLivenessTimeoutCbh = CallbackHandle(); + // Only reset the callback handle if it matches, otherwise more will be coming through + if (cbData.myHandle == _handleLivenessTimeoutCbh) { + _handleLivenessTimeoutCbh = CallbackHandle(); + } else { + warning() << "The liveness timeout does not match callback handle, so not resetting it."; + } if (!cbData.status.isOK()) { return; } diff --git a/src/mongo/db/repl/replication_executor.cpp b/src/mongo/db/repl/replication_executor.cpp index c72f3c16ac7..d905f3b1fdd 100644 --- a/src/mongo/db/repl/replication_executor.cpp +++ b/src/mongo/db/repl/replication_executor.cpp @@ -595,6 +595,11 @@ ReplicationExecutor::Callback::Callback(ReplicationExecutor* executor, ReplicationExecutor::Callback::~Callback() {} +bool ReplicationExecutor::Callback::isCanceled() const { + stdx::unique_lock<stdx::mutex> lk(_executor->_mutex); + return _isCanceled; +} + void ReplicationExecutor::Callback::cancel() { stdx::unique_lock<stdx::mutex> lk(_executor->_mutex); _isCanceled = true; diff --git a/src/mongo/db/repl/replication_executor.h b/src/mongo/db/repl/replication_executor.h index 24d3e67421e..0684ba63071 100644 --- a/src/mongo/db/repl/replication_executor.h +++ b/src/mongo/db/repl/replication_executor.h @@ -353,9 +353,7 @@ public: void cancel() override; void waitForCompletion() override; - bool isCanceled() const override { - return _isCanceled; - } + bool isCanceled() const override; private: ReplicationExecutor* _executor; |