From 51463ed9e3fca4667c72d82be539c061e7bed63e Mon Sep 17 00:00:00 2001 From: Vishnu Kaushik Date: Thu, 15 Jul 2021 18:47:24 +0000 Subject: SERVER-58594 ReplicationCoordinatorImpl::handleHeartbeatResponse_forTest doesn't use _mutex when reading _rsConfig --- src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp | 10 ++++++---- 1 file changed, 6 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 451aaf94c95..3294467da68 100644 --- a/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp @@ -150,14 +150,12 @@ void ReplicationCoordinatorImpl::handleHeartbeatResponse_forTest(BSONObj respons Milliseconds ping) { CallbackHandle handle; RemoteCommandRequest request; - request.target = _rsConfig.getMemberAt(targetIndex).getHostAndPort(); - executor::TaskExecutor::ResponseStatus status(response, ping); - executor::TaskExecutor::RemoteCommandCallbackArgs cbData( - _replExecutor.get(), handle, request, status); { stdx::unique_lock lk(_mutex); + request.target = _rsConfig.getMemberAt(targetIndex).getHostAndPort(); + // Simulate preparing a heartbeat request so that the target's ping stats are initialized. _topCoord->prepareHeartbeatRequestV1( _replExecutor->now(), _rsConfig.getReplSetName(), request.target); @@ -166,6 +164,10 @@ void ReplicationCoordinatorImpl::handleHeartbeatResponse_forTest(BSONObj respons _trackHeartbeatHandle_inlock(handle, HeartbeatState::kSent, request.target); } + executor::TaskExecutor::ResponseStatus status(response, ping); + executor::TaskExecutor::RemoteCommandCallbackArgs cbData( + _replExecutor.get(), handle, request, status); + _handleHeartbeatResponse(cbData); } -- cgit v1.2.1