summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuganthi Mani <suganthi.mani@mongodb.com>2018-06-21 14:07:21 -0400
committersmani87 <suganthi.mani@mongodb.com>2018-06-28 09:54:58 -0400
commit1be62ec4da5968f243e949dfb3cab68157f6ef1c (patch)
tree38a9f0e3f37575cedb67353fe72d514d20f27201
parentedff161ae08327f17f284bac638bdebc72404421 (diff)
downloadmongo-1be62ec4da5968f243e949dfb3cab68157f6ef1c.tar.gz
SERVER-31963 Remove heartbeat support for pv0.
-rw-r--r--src/mongo/db/repl/SConscript1
-rw-r--r--src/mongo/db/repl/check_quorum_for_config_change.cpp35
-rw-r--r--src/mongo/db/repl/repl_set_commands.cpp42
-rw-r--r--src/mongo/db/repl/repl_set_heartbeat_args.cpp200
-rw-r--r--src/mongo/db/repl/repl_set_heartbeat_args.h172
-rw-r--r--src/mongo/db/repl/replication_coordinator.h3
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.cpp39
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.h3
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp17
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_heartbeat_v1_test.cpp1
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_test.cpp1
-rw-r--r--src/mongo/db/repl/replication_coordinator_mock.cpp5
-rw-r--r--src/mongo/db/repl/replication_coordinator_mock.h3
-rw-r--r--src/mongo/db/repl/replication_coordinator_test_fixture.cpp22
-rw-r--r--src/mongo/db/repl/replication_coordinator_test_fixture.h1
-rw-r--r--src/mongo/db/repl/topology_coordinator.cpp133
-rw-r--r--src/mongo/db/repl/topology_coordinator.h11
-rw-r--r--src/mongo/db/repl/topology_coordinator_v1_test.cpp1
-rw-r--r--src/mongo/embedded/replication_coordinator_embedded.cpp5
-rw-r--r--src/mongo/embedded/replication_coordinator_embedded.h3
20 files changed, 21 insertions, 677 deletions
diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript
index ac1d6cb6f04..8410c0b36c0 100644
--- a/src/mongo/db/repl/SConscript
+++ b/src/mongo/db/repl/SConscript
@@ -1020,7 +1020,6 @@ env.Library('replica_set_messages',
'is_master_response.cpp',
'member_config.cpp',
'repl_set_config.cpp',
- 'repl_set_heartbeat_args.cpp',
'repl_set_heartbeat_args_v1.cpp',
'repl_set_heartbeat_response.cpp',
'repl_set_html_summary.cpp',
diff --git a/src/mongo/db/repl/check_quorum_for_config_change.cpp b/src/mongo/db/repl/check_quorum_for_config_change.cpp
index 3d59066ca7b..1c4bbaa6c68 100644
--- a/src/mongo/db/repl/check_quorum_for_config_change.cpp
+++ b/src/mongo/db/repl/check_quorum_for_config_change.cpp
@@ -35,7 +35,6 @@
#include "mongo/base/disallow_copying.h"
#include "mongo/base/status.h"
#include "mongo/db/repl/repl_set_config.h"
-#include "mongo/db/repl/repl_set_heartbeat_args.h"
#include "mongo/db/repl/repl_set_heartbeat_args_v1.h"
#include "mongo/db/repl/repl_set_heartbeat_response.h"
#include "mongo/db/repl/scatter_gather_algorithm.h"
@@ -85,30 +84,18 @@ std::vector<RemoteCommandRequest> QuorumChecker::getRequests() const {
}
BSONObj hbRequest;
- if (_term == OpTime::kUninitializedTerm) {
- ReplSetHeartbeatArgs hbArgs;
- hbArgs.setSetName(_rsConfig->getReplSetName());
- hbArgs.setProtocolVersion(1);
- hbArgs.setConfigVersion(_rsConfig->getConfigVersion());
- hbArgs.setHeartbeatVersion(1);
- hbArgs.setCheckEmpty(isInitialConfig);
- hbArgs.setSenderHost(myConfig.getHostAndPort());
- hbArgs.setSenderId(myConfig.getId());
- hbRequest = hbArgs.toBSON();
-
- } else {
- ReplSetHeartbeatArgsV1 hbArgs;
- hbArgs.setSetName(_rsConfig->getReplSetName());
- hbArgs.setConfigVersion(_rsConfig->getConfigVersion());
- hbArgs.setHeartbeatVersion(1);
- if (isInitialConfig) {
- hbArgs.setCheckEmpty();
- }
- hbArgs.setSenderHost(myConfig.getHostAndPort());
- hbArgs.setSenderId(myConfig.getId());
- hbArgs.setTerm(_term);
- hbRequest = hbArgs.toBSON();
+ invariant(_term != OpTime::kUninitializedTerm);
+ ReplSetHeartbeatArgsV1 hbArgs;
+ hbArgs.setSetName(_rsConfig->getReplSetName());
+ hbArgs.setConfigVersion(_rsConfig->getConfigVersion());
+ hbArgs.setHeartbeatVersion(1);
+ if (isInitialConfig) {
+ hbArgs.setCheckEmpty();
}
+ hbArgs.setSenderHost(myConfig.getHostAndPort());
+ hbArgs.setSenderId(myConfig.getId());
+ hbArgs.setTerm(_term);
+ hbRequest = hbArgs.toBSON();
// Send a bunch of heartbeat requests.
// Schedule an operation when a "sufficient" number of them have completed, and use that
diff --git a/src/mongo/db/repl/repl_set_commands.cpp b/src/mongo/db/repl/repl_set_commands.cpp
index 103612358d2..d50b2ca34f2 100644
--- a/src/mongo/db/repl/repl_set_commands.cpp
+++ b/src/mongo/db/repl/repl_set_commands.cpp
@@ -51,7 +51,6 @@
#include "mongo/db/op_observer.h"
#include "mongo/db/repl/drop_pending_collection_reaper.h"
#include "mongo/db/repl/oplog.h"
-#include "mongo/db/repl/repl_set_heartbeat_args.h"
#include "mongo/db/repl/repl_set_heartbeat_args_v1.h"
#include "mongo/db/repl/repl_set_heartbeat_response.h"
#include "mongo/db/repl/replication_coordinator.h"
@@ -637,12 +636,6 @@ bool replHasDatabases(OperationContext* opCtx) {
return false;
}
-const std::string kHeartbeatConfigVersion = "configVersion";
-
-bool isHeartbeatRequestV1(const BSONObj& cmdObj) {
- return cmdObj.hasField(kHeartbeatConfigVersion);
-}
-
} // namespace
MONGO_FAIL_POINT_DEFINE(rsDelayHeartbeatResponse);
@@ -671,40 +664,13 @@ public:
uassertStatusOK(status);
}
- // Process heartbeat based on the version of request. The missing fields in mismatched
- // version will be empty.
- if (isHeartbeatRequestV1(cmdObj)) {
- ReplSetHeartbeatArgsV1 args;
- status = args.initialize(cmdObj);
- if (status.isOK()) {
- ReplSetHeartbeatResponse response;
- status = ReplicationCoordinator::get(opCtx)->processHeartbeatV1(args, &response);
- if (status.isOK())
- response.addToBSON(&result, true);
-
- LOG_FOR_HEARTBEATS(2) << "Processed heartbeat from "
- << cmdObj.getStringField("from")
- << " and generated response, " << response;
- uassertStatusOK(status);
- return true;
- }
- // else: fall through to old heartbeat protocol as it is likely that
- // a new node just joined the set
- }
-
- ReplSetHeartbeatArgs args;
- status = args.initialize(cmdObj);
- uassertStatusOK(status);
-
- // ugh.
- if (args.getCheckEmpty()) {
- result.append("hasData", replHasDatabases(opCtx));
- }
+ ReplSetHeartbeatArgsV1 args;
+ uassertStatusOK(args.initialize(cmdObj));
ReplSetHeartbeatResponse response;
- status = ReplicationCoordinator::get(opCtx)->processHeartbeat(args, &response);
+ status = ReplicationCoordinator::get(opCtx)->processHeartbeatV1(args, &response);
if (status.isOK())
- response.addToBSON(&result, false);
+ response.addToBSON(&result, true);
LOG_FOR_HEARTBEATS(2) << "Processed heartbeat from " << cmdObj.getStringField("from")
<< " and generated response, " << response;
diff --git a/src/mongo/db/repl/repl_set_heartbeat_args.cpp b/src/mongo/db/repl/repl_set_heartbeat_args.cpp
deleted file mode 100644
index 5b75f97c516..00000000000
--- a/src/mongo/db/repl/repl_set_heartbeat_args.cpp
+++ /dev/null
@@ -1,200 +0,0 @@
-/**
- * Copyright 2014 MongoDB Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * As a special exception, the copyright holders give permission to link the
- * code of portions of this program with the OpenSSL library under certain
- * conditions as described in each individual source file and distribute
- * linked combinations including the program with the OpenSSL library. You
- * must comply with the GNU Affero General Public License in all respects for
- * all of the code used other than as permitted herein. If you modify file(s)
- * with this exception, you may extend this exception to your version of the
- * file(s), but you are not obligated to do so. If you do not wish to do so,
- * delete this exception statement from your version. If you delete this
- * exception statement from all source files in the program, then also delete
- * it in the license file.
- */
-
-#include "mongo/platform/basic.h"
-
-#include "mongo/db/repl/repl_set_heartbeat_args.h"
-
-#include "mongo/bson/util/bson_check.h"
-#include "mongo/bson/util/bson_extract.h"
-#include "mongo/db/jsobj.h"
-
-namespace mongo {
-namespace repl {
-
-namespace {
-
-const std::string kCheckEmptyFieldName = "checkEmpty";
-const std::string kProtocolVersionFieldName = "pv";
-const std::string kConfigVersionFieldName = "v";
-const std::string kHeartbeatVersionFieldName = "hbv";
-const std::string kSenderIdFieldName = "fromId";
-const std::string kSetNameFieldName = "replSetHeartbeat";
-const std::string kSenderHostFieldName = "from";
-
-const std::string kLegalHeartbeatFieldNames[] = {kCheckEmptyFieldName,
- kProtocolVersionFieldName,
- kConfigVersionFieldName,
- kHeartbeatVersionFieldName,
- kSenderIdFieldName,
- kSetNameFieldName,
- kSenderHostFieldName};
-
-} // namespace
-
-ReplSetHeartbeatArgs::ReplSetHeartbeatArgs()
- : _hasCheckEmpty(false),
- _hasProtocolVersion(false),
- _hasConfigVersion(false),
- _hasHeartbeatVersion(false),
- _hasSenderId(false),
- _hasSetName(false),
- _hasSenderHost(false),
- _checkEmpty(false),
- _protocolVersion(-1),
- _configVersion(-1),
- _heartbeatVersion(-1),
- _senderId(-1),
- _setName(""),
- _senderHost(HostAndPort()) {}
-
-Status ReplSetHeartbeatArgs::initialize(const BSONObj& argsObj) {
- Status status = bsonCheckOnlyHasFieldsForCommand(
- "ReplSetHeartbeatArgs", argsObj, kLegalHeartbeatFieldNames);
- if (!status.isOK())
- return status;
-
- status = bsonExtractBooleanFieldWithDefault(argsObj, kCheckEmptyFieldName, false, &_checkEmpty);
- if (!status.isOK())
- return status;
- _hasCheckEmpty = true;
-
- status = bsonExtractIntegerField(argsObj, kProtocolVersionFieldName, &_protocolVersion);
- if (!status.isOK())
- return status;
- _hasProtocolVersion = true;
-
- status = bsonExtractIntegerField(argsObj, kConfigVersionFieldName, &_configVersion);
- if (!status.isOK())
- return status;
- _hasConfigVersion = true;
-
- long long tempHeartbeatVersion;
- status = bsonExtractIntegerField(argsObj, kHeartbeatVersionFieldName, &tempHeartbeatVersion);
- if (status.isOK()) {
- if (tempHeartbeatVersion != 1) {
- return Status(ErrorCodes::Error(40665),
- str::stream() << "Found invalid value for field "
- << kHeartbeatVersionFieldName
- << ": "
- << tempHeartbeatVersion);
- }
- _heartbeatVersion = tempHeartbeatVersion;
- _hasHeartbeatVersion = true;
- } else if (status.code() != ErrorCodes::NoSuchKey) {
- return status;
- }
-
- status = bsonExtractIntegerFieldWithDefault(argsObj, kSenderIdFieldName, -1, &_senderId);
- if (!status.isOK())
- return status;
- _hasSenderId = true;
-
- status = bsonExtractStringField(argsObj, kSetNameFieldName, &_setName);
- if (!status.isOK())
- return status;
- _hasSetName = true;
-
- std::string hostAndPortString;
- status =
- bsonExtractStringFieldWithDefault(argsObj, kSenderHostFieldName, "", &hostAndPortString);
- if (!status.isOK())
- return status;
-
- if (!hostAndPortString.empty()) {
- status = _senderHost.initialize(hostAndPortString);
- if (!status.isOK())
- return status;
- _hasSenderHost = true;
- }
-
- return Status::OK();
-}
-
-bool ReplSetHeartbeatArgs::isInitialized() const {
- return _hasProtocolVersion && _hasConfigVersion && _hasSetName;
-}
-
-BSONObj ReplSetHeartbeatArgs::toBSON() const {
- invariant(isInitialized());
- BSONObjBuilder builder;
- builder.append("replSetHeartbeat", _setName);
- builder.appendIntOrLL("pv", _protocolVersion);
- builder.appendIntOrLL("v", _configVersion);
- if (_hasHeartbeatVersion) {
- builder.append("hbv", _heartbeatVersion);
- }
-
- builder.append("from", _hasSenderHost ? _senderHost.toString() : "");
-
- if (_hasSenderId) {
- builder.appendIntOrLL("fromId", _senderId);
- }
- if (_hasCheckEmpty) {
- builder.append("checkEmpty", _checkEmpty);
- }
- return builder.obj();
-}
-
-void ReplSetHeartbeatArgs::setCheckEmpty(bool newVal) {
- _checkEmpty = newVal;
- _hasCheckEmpty = true;
-}
-
-void ReplSetHeartbeatArgs::setProtocolVersion(long long newVal) {
- _protocolVersion = newVal;
- _hasProtocolVersion = true;
-}
-
-void ReplSetHeartbeatArgs::setConfigVersion(long long newVal) {
- _configVersion = newVal;
- _hasConfigVersion = true;
-}
-
-void ReplSetHeartbeatArgs::setHeartbeatVersion(long long newVal) {
- _heartbeatVersion = newVal;
- _hasHeartbeatVersion = true;
-}
-
-void ReplSetHeartbeatArgs::setSenderId(long long newVal) {
- _senderId = newVal;
- _hasSenderId = true;
-}
-
-void ReplSetHeartbeatArgs::setSetName(std::string newVal) {
- _setName = newVal;
- _hasSetName = true;
-}
-
-void ReplSetHeartbeatArgs::setSenderHost(HostAndPort newVal) {
- _senderHost = newVal;
- _hasSenderHost = true;
-}
-
-} // namespace repl
-} // namespace mongo
diff --git a/src/mongo/db/repl/repl_set_heartbeat_args.h b/src/mongo/db/repl/repl_set_heartbeat_args.h
deleted file mode 100644
index 40e8e180312..00000000000
--- a/src/mongo/db/repl/repl_set_heartbeat_args.h
+++ /dev/null
@@ -1,172 +0,0 @@
-/**
- * Copyright (C) 2014 MongoDB Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * As a special exception, the copyright holders give permission to link the
- * code of portions of this program with the OpenSSL library under certain
- * conditions as described in each individual source file and distribute
- * linked combinations including the program with the OpenSSL library. You
- * must comply with the GNU Affero General Public License in all respects for
- * all of the code used other than as permitted herein. If you modify file(s)
- * with this exception, you may extend this exception to your version of the
- * file(s), but you are not obligated to do so. If you do not wish to do so,
- * delete this exception statement from your version. If you delete this
- * exception statement from all source files in the program, then also delete
- * it in the license file.
- */
-
-#pragma once
-
-#include <string>
-
-#include "mongo/util/net/hostandport.h"
-
-namespace mongo {
-
-class BSONObj;
-class Status;
-
-namespace repl {
-
-/**
- * Arguments to the replSetHeartbeat command.
- */
-class ReplSetHeartbeatArgs {
-public:
- ReplSetHeartbeatArgs();
-
- /**
- * Initializes this ReplSetHeartbeatArgs from the contents of args.
- */
- Status initialize(const BSONObj& argsObj);
-
- /**
- * Returns true if all required fields have been initialized.
- */
- bool isInitialized() const;
-
- /**
- * Returns whether the sender would like to know whether the node is empty or not.
- */
- bool getCheckEmpty() const {
- return _checkEmpty;
- }
-
- /**
- * Gets the version of the Heartbeat protocol being used by the sender.
- */
- long long getProtocolVersion() const {
- return _protocolVersion;
- }
-
- /**
- * Gets the ReplSetConfig version number of the sender.
- */
- long long getConfigVersion() const {
- return _configVersion;
- }
-
- /**
- * Gets the heartbeat version number of the sender. This field was added to ensure that
- * heartbeats sent from featureCompatibilityVersion 3.6 nodes to binary version 3.4 nodes fail.
- */
- long long getHeartbeatVersion() const {
- return _heartbeatVersion;
- }
-
- /**
- * Gets the _id of the sender in their ReplSetConfig.
- */
- long long getSenderId() const {
- return _senderId;
- }
-
- /**
- * Gets the replSet name of the sender's replica set.
- */
- std::string getSetName() const {
- return _setName;
- }
-
- /**
- * Gets the HostAndPort of the sender.
- */
- HostAndPort getSenderHost() const {
- return _senderHost;
- }
-
- /**
- * The below methods check whether or not value in the method name has been set.
- */
- bool hasCheckEmpty() const {
- return _hasCheckEmpty;
- }
- bool hasProtocolVersion() const {
- return _hasProtocolVersion;
- }
- bool hasConfigVersion() const {
- return _hasConfigVersion;
- }
- bool hasHeartbeatVersion() const {
- return _hasHeartbeatVersion;
- }
- bool hasSenderId() const {
- return _hasSenderId;
- }
- bool hasSetName() const {
- return _hasSetName;
- }
- bool hasSenderHost() const {
- return _hasSenderHost;
- }
-
- /**
- * The below methods set the value in the method name to 'newVal'.
- */
- void setCheckEmpty(bool newVal);
- void setProtocolVersion(long long newVal);
- void setConfigVersion(long long newVal);
- void setHeartbeatVersion(long long newVal);
- void setSenderId(long long newVal);
- void setSetName(std::string newVal);
- void setSenderHost(HostAndPort newVal);
-
- /**
- * Returns a BSONified version of the object.
- * Should only be called if the mandatory fields have been set.
- * Optional fields are only included if they have been set.
- */
- BSONObj toBSON() const;
-
-private:
- bool _hasCheckEmpty;
- bool _hasProtocolVersion;
- bool _hasConfigVersion;
- bool _hasHeartbeatVersion;
- bool _hasSenderId;
- bool _hasSetName;
- bool _hasSenderHost;
-
- // look at the body of the isInitialized() function to see which fields are mandatory
- bool _checkEmpty;
- long long _protocolVersion;
- long long _configVersion;
- long long _heartbeatVersion;
- long long _senderId;
- std::string _setName;
- HostAndPort _senderHost;
-};
-
-} // namespace repl
-} // namespace mongo
diff --git a/src/mongo/db/repl/replication_coordinator.h b/src/mongo/db/repl/replication_coordinator.h
index 35ce0c99470..64076214596 100644
--- a/src/mongo/db/repl/replication_coordinator.h
+++ b/src/mongo/db/repl/replication_coordinator.h
@@ -70,7 +70,6 @@ class OplogReader;
class OpTime;
class ReadConcernArgs;
class ReplSetConfig;
-class ReplSetHeartbeatArgs;
class ReplSetHeartbeatArgsV1;
class ReplSetHeartbeatResponse;
class ReplSetHtmlSummary;
@@ -586,8 +585,6 @@ public:
* Handles an incoming heartbeat command with arguments 'args'. Populates 'response';
* returns a Status with either OK or an error message.
*/
- virtual Status processHeartbeat(const ReplSetHeartbeatArgs& args,
- ReplSetHeartbeatResponse* response) = 0;
virtual Status processHeartbeatV1(const ReplSetHeartbeatArgsV1& args,
ReplSetHeartbeatResponse* response) = 0;
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp
index 5b786bc9624..6745876de51 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl.cpp
@@ -55,7 +55,6 @@
#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/repl/repl_client_info.h"
#include "mongo/db/repl/repl_set_config_checks.h"
-#include "mongo/db/repl/repl_set_heartbeat_args.h"
#include "mongo/db/repl/repl_set_heartbeat_args_v1.h"
#include "mongo/db/repl/repl_set_heartbeat_response.h"
#include "mongo/db/repl/repl_set_html_summary.h"
@@ -2142,44 +2141,6 @@ Status ReplicationCoordinatorImpl::processReplSetFreeze(int secs, BSONObjBuilder
return Status::OK();
}
-Status ReplicationCoordinatorImpl::processHeartbeat(const ReplSetHeartbeatArgs& args,
- ReplSetHeartbeatResponse* response) {
- {
- stdx::lock_guard<stdx::mutex> lock(_mutex);
- if (_rsConfigState == kConfigPreStart || _rsConfigState == kConfigStartingUp) {
- return Status(ErrorCodes::NotYetInitialized,
- "Received heartbeat while still initializing replication system");
- }
- }
-
- auto senderHost(args.getSenderHost());
-
- stdx::lock_guard<stdx::mutex> lk(_mutex);
-
- const Date_t now = _replExecutor->now();
- Status result =
- _topCoord->prepareHeartbeatResponse(now, args, _settings.ourSetName(), response);
- if ((result.isOK() || result == ErrorCodes::InvalidReplicaSetConfig) && _selfIndex < 0) {
- // If this node does not belong to the configuration it knows about, send heartbeats
- // back to any node that sends us a heartbeat, in case one of those remote nodes has
- // a configuration that contains us. Chances are excellent that it will, since that
- // is the only reason for a remote node to send this node a heartbeat request.
- if (!senderHost.empty() && _seedList.insert(senderHost).second) {
- _scheduleHeartbeatToTarget_inlock(senderHost, -1, now);
- }
- } else if (result.isOK() && response->getConfigVersion() < args.getConfigVersion()) {
- // Schedule a heartbeat to the sender to fetch the new config.
- // We cannot cancel the enqueued heartbeat, but either this one or the enqueued heartbeat
- // will trigger reconfig, which cancels and reschedules all heartbeats.
-
- if (args.hasSenderHost()) {
- int senderIndex = _rsConfig.findMemberIndexByHostAndPort(senderHost);
- _scheduleHeartbeatToTarget_inlock(senderHost, senderIndex, now);
- }
- }
- return result;
-}
-
Status ReplicationCoordinatorImpl::processReplSetReconfig(OperationContext* opCtx,
const ReplSetReconfigArgs& args,
BSONObjBuilder* resultObj) {
diff --git a/src/mongo/db/repl/replication_coordinator_impl.h b/src/mongo/db/repl/replication_coordinator_impl.h
index fc57c21f86b..b8bb050cd1b 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.h
+++ b/src/mongo/db/repl/replication_coordinator_impl.h
@@ -211,9 +211,6 @@ public:
virtual Status processReplSetFreeze(int secs, BSONObjBuilder* resultObj) override;
- virtual Status processHeartbeat(const ReplSetHeartbeatArgs& args,
- ReplSetHeartbeatResponse* response) override;
-
virtual Status processReplSetReconfig(OperationContext* opCtx,
const ReplSetReconfigArgs& args,
BSONObjBuilder* resultObj) override;
diff --git a/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp b/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp
index 7ef149b7224..28b2a427b96 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_heartbeat.cpp
@@ -42,7 +42,6 @@
#include "mongo/db/repl/freshness_checker.h"
#include "mongo/db/repl/heartbeat_response_action.h"
#include "mongo/db/repl/repl_set_config_checks.h"
-#include "mongo/db/repl/repl_set_heartbeat_args.h"
#include "mongo/db/repl/repl_set_heartbeat_args_v1.h"
#include "mongo/db/repl/repl_set_heartbeat_response.h"
#include "mongo/db/repl/replication_coordinator_impl.h"
@@ -98,17 +97,11 @@ void ReplicationCoordinatorImpl::_doMemberHeartbeat(executor::TaskExecutor::Call
const Date_t now = _replExecutor->now();
BSONObj heartbeatObj;
Milliseconds timeout(0);
- if (isV1ElectionProtocol()) {
- const std::pair<ReplSetHeartbeatArgsV1, Milliseconds> hbRequest =
- _topCoord->prepareHeartbeatRequestV1(now, _settings.ourSetName(), target);
- heartbeatObj = hbRequest.first.toBSON();
- timeout = hbRequest.second;
- } else {
- const std::pair<ReplSetHeartbeatArgs, Milliseconds> hbRequest =
- _topCoord->prepareHeartbeatRequest(now, _settings.ourSetName(), target);
- heartbeatObj = hbRequest.first.toBSON();
- timeout = hbRequest.second;
- }
+ invariant(isV1ElectionProtocol());
+ const std::pair<ReplSetHeartbeatArgsV1, Milliseconds> hbRequest =
+ _topCoord->prepareHeartbeatRequestV1(now, _settings.ourSetName(), target);
+ heartbeatObj = hbRequest.first.toBSON();
+ timeout = hbRequest.second;
const RemoteCommandRequest request(
target, "admin", heartbeatObj, BSON(rpc::kReplSetMetadataFieldName << 1), nullptr, timeout);
diff --git a/src/mongo/db/repl/replication_coordinator_impl_heartbeat_v1_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_heartbeat_v1_test.cpp
index 2637deed13a..05a9c1281fc 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_heartbeat_v1_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_heartbeat_v1_test.cpp
@@ -34,7 +34,6 @@
#include "mongo/db/jsobj.h"
#include "mongo/db/operation_context_noop.h"
#include "mongo/db/repl/repl_set_config.h"
-#include "mongo/db/repl/repl_set_heartbeat_args.h"
#include "mongo/db/repl/repl_set_heartbeat_args_v1.h"
#include "mongo/db/repl/replication_coordinator_external_state_mock.h"
#include "mongo/db/repl/replication_coordinator_impl.h"
diff --git a/src/mongo/db/repl/replication_coordinator_impl_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_test.cpp
index d009a9914fc..a40e0c6a015 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_test.cpp
@@ -44,7 +44,6 @@
#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/repl/repl_client_info.h"
#include "mongo/db/repl/repl_set_config.h"
-#include "mongo/db/repl/repl_set_heartbeat_args.h"
#include "mongo/db/repl/repl_set_heartbeat_args_v1.h"
#include "mongo/db/repl/repl_set_request_votes_args.h"
#include "mongo/db/repl/repl_settings.h"
diff --git a/src/mongo/db/repl/replication_coordinator_mock.cpp b/src/mongo/db/repl/replication_coordinator_mock.cpp
index cc8aca366e2..78352752f51 100644
--- a/src/mongo/db/repl/replication_coordinator_mock.cpp
+++ b/src/mongo/db/repl/replication_coordinator_mock.cpp
@@ -320,11 +320,6 @@ Status ReplicationCoordinatorMock::processReplSetFreeze(int secs, BSONObjBuilder
return Status::OK();
}
-Status ReplicationCoordinatorMock::processHeartbeat(const ReplSetHeartbeatArgs& args,
- ReplSetHeartbeatResponse* response) {
- return Status::OK();
-}
-
Status ReplicationCoordinatorMock::processReplSetReconfig(OperationContext* opCtx,
const ReplSetReconfigArgs& args,
BSONObjBuilder* resultObj) {
diff --git a/src/mongo/db/repl/replication_coordinator_mock.h b/src/mongo/db/repl/replication_coordinator_mock.h
index 973c2afb15b..d1c1f87f927 100644
--- a/src/mongo/db/repl/replication_coordinator_mock.h
+++ b/src/mongo/db/repl/replication_coordinator_mock.h
@@ -178,9 +178,6 @@ public:
virtual Status processReplSetFreeze(int secs, BSONObjBuilder* resultObj);
- virtual Status processHeartbeat(const ReplSetHeartbeatArgs& args,
- ReplSetHeartbeatResponse* response);
-
virtual Status processReplSetReconfig(OperationContext* opCtx,
const ReplSetReconfigArgs& args,
BSONObjBuilder* resultObj);
diff --git a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
index 7b2defbe0ad..23347464610 100644
--- a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
+++ b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
@@ -35,7 +35,6 @@
#include "mongo/db/logical_clock.h"
#include "mongo/db/operation_context_noop.h"
#include "mongo/db/repl/is_master_response.h"
-#include "mongo/db/repl/repl_set_heartbeat_args.h"
#include "mongo/db/repl/repl_set_heartbeat_args_v1.h"
#include "mongo/db/repl/repl_settings.h"
#include "mongo/db/repl/replication_consistency_markers_mock.h"
@@ -234,7 +233,6 @@ void ReplCoordTest::simulateEnoughHeartbeatsForAllNodesUp() {
const RemoteCommandRequest& request = noi->getRequest();
log() << request.target.toString() << " processing " << request.cmdObj;
ReplSetHeartbeatArgsV1 hbArgs;
- ReplSetHeartbeatArgs hbArgsPV0;
if (hbArgs.initialize(request.cmdObj).isOK()) {
ReplSetHeartbeatResponse hbResp;
hbResp.setSetName(rsConfig.getReplSetName());
@@ -414,26 +412,6 @@ void ReplCoordTest::shutdown(OperationContext* opCtx) {
_callShutdown = false;
}
-void ReplCoordTest::replyToReceivedHeartbeat() {
- NetworkInterfaceMock* net = getNet();
- net->enterNetwork();
- const NetworkInterfaceMock::NetworkOperationIterator noi = net->getNextReadyRequest();
- const RemoteCommandRequest& request = noi->getRequest();
- const ReplSetConfig rsConfig = getReplCoord()->getReplicaSetConfig_forTest();
- repl::ReplSetHeartbeatArgs hbArgs;
- ASSERT_OK(hbArgs.initialize(request.cmdObj));
- repl::ReplSetHeartbeatResponse hbResp;
- hbResp.setSetName(rsConfig.getReplSetName());
- hbResp.setState(MemberState::RS_SECONDARY);
- hbResp.setConfigVersion(rsConfig.getConfigVersion());
- BSONObjBuilder respObj;
- respObj << "ok" << 1;
- hbResp.addToBSON(&respObj, false);
- net->scheduleResponse(noi, net->now(), makeResponseStatus(respObj.obj()));
- net->runReadyNetworkOperations();
- getNet()->exitNetwork();
-}
-
void ReplCoordTest::replyToReceivedHeartbeatV1() {
NetworkInterfaceMock* net = getNet();
net->enterNetwork();
diff --git a/src/mongo/db/repl/replication_coordinator_test_fixture.h b/src/mongo/db/repl/replication_coordinator_test_fixture.h
index 3f0cb66f838..b5718a65a70 100644
--- a/src/mongo/db/repl/replication_coordinator_test_fixture.h
+++ b/src/mongo/db/repl/replication_coordinator_test_fixture.h
@@ -238,7 +238,6 @@ protected:
/**
* Receive the heartbeat request from replication coordinator and reply with a response.
*/
- void replyToReceivedHeartbeat();
void replyToReceivedHeartbeatV1();
/**
* Consumes the network operation and responds if it's a heartbeat request.
diff --git a/src/mongo/db/repl/topology_coordinator.cpp b/src/mongo/db/repl/topology_coordinator.cpp
index eb9d23437f2..68ce62956a1 100644
--- a/src/mongo/db/repl/topology_coordinator.cpp
+++ b/src/mongo/db/repl/topology_coordinator.cpp
@@ -44,7 +44,6 @@
#include "mongo/db/repl/is_master_response.h"
#include "mongo/db/repl/isself.h"
#include "mongo/db/repl/member_data.h"
-#include "mongo/db/repl/repl_set_heartbeat_args.h"
#include "mongo/db/repl/repl_set_heartbeat_args_v1.h"
#include "mongo/db/repl/repl_set_heartbeat_response.h"
#include "mongo/db/repl/repl_set_html_summary.h"
@@ -759,103 +758,6 @@ void TopologyCoordinator::prepareElectResponse(const ReplicationCoordinator::Rep
}
// produce a reply to a heartbeat
-Status TopologyCoordinator::prepareHeartbeatResponse(Date_t now,
- const ReplSetHeartbeatArgs& args,
- const std::string& ourSetName,
- ReplSetHeartbeatResponse* response) {
- if (args.getProtocolVersion() != 1) {
- return Status(ErrorCodes::BadValue,
- str::stream() << "replset: incompatible replset protocol version: "
- << args.getProtocolVersion());
- }
-
- // Verify that replica set names match
- const std::string rshb = args.getSetName();
- if (ourSetName != rshb) {
- log() << "replSet set names do not match, ours: " << ourSetName
- << "; remote node's: " << rshb;
- response->noteMismatched();
- return Status(ErrorCodes::InconsistentReplicaSetNames,
- str::stream() << "Our set name of " << ourSetName << " does not match name "
- << rshb
- << " reported by remote node");
- }
-
- const MemberState myState = getMemberState();
- if (_selfIndex == -1) {
- if (myState.removed()) {
- return Status(ErrorCodes::InvalidReplicaSetConfig,
- "Our replica set configuration is invalid or does not include us");
- }
- } else {
- invariant(_rsConfig.getReplSetName() == args.getSetName());
- if (args.getSenderId() == _selfConfig().getId()) {
- return Status(ErrorCodes::BadValue,
- str::stream() << "Received heartbeat from member with the same "
- "member ID as ourself: "
- << args.getSenderId());
- }
- }
-
- // This is a replica set
- response->noteReplSet();
-
- response->setSetName(ourSetName);
- response->setState(myState.s);
- if (myState.primary()) {
- response->setElectionTime(_electionTime);
- }
-
- const OpTime lastOpApplied = getMyLastAppliedOpTime();
- const OpTime lastOpDurable = getMyLastDurableOpTime();
-
- // Are we electable
- response->setElectable(!_getMyUnelectableReason(now, StartElectionReason::kElectionTimeout));
-
- // Heartbeat status message
- response->setHbMsg(_getHbmsg(now));
- response->setTime(duration_cast<Seconds>(now - Date_t{}));
- response->setAppliedOpTime(lastOpApplied);
- response->setDurableOpTime(lastOpDurable);
-
- if (!_syncSource.empty()) {
- response->setSyncingTo(_syncSource);
- }
-
- if (!_rsConfig.isInitialized()) {
- response->setConfigVersion(-2);
- return Status::OK();
- }
-
- const long long v = _rsConfig.getConfigVersion();
- response->setConfigVersion(v);
- // Deliver new config if caller's version is older than ours
- if (v > args.getConfigVersion()) {
- response->setConfig(_rsConfig);
- }
-
- // Resolve the caller's id in our Member list
- int from = -1;
- if (v == args.getConfigVersion() && args.getSenderId() != -1) {
- from = _getMemberIndex(args.getSenderId());
- }
- if (from == -1) {
- // Can't find the member, so we leave out the stateDisagreement field
- return Status::OK();
- }
- invariant(from != _selfIndex);
-
- auto& fromNodeData = _memberData.at(from);
- // if we thought that this node is down, let it know
- if (!fromNodeData.up()) {
- response->noteStateDisagreement();
- }
-
- // note that we got a heartbeat from this node
- fromNodeData.setLastHeartbeatRecv(now);
- return Status::OK();
-}
-
Status TopologyCoordinator::prepareHeartbeatResponseV1(Date_t now,
const ReplSetHeartbeatArgsV1& args,
const std::string& ourSetName,
@@ -950,41 +852,6 @@ int TopologyCoordinator::_getMemberIndex(int id) const {
return -1;
}
-std::pair<ReplSetHeartbeatArgs, Milliseconds> TopologyCoordinator::prepareHeartbeatRequest(
- Date_t now, const std::string& ourSetName, const HostAndPort& target) {
- PingStats& hbStats = _pings[target];
- Milliseconds alreadyElapsed = now - hbStats.getLastHeartbeatStartDate();
- if (!_rsConfig.isInitialized() || !hbStats.trying() ||
- (alreadyElapsed >= _rsConfig.getHeartbeatTimeoutPeriodMillis())) {
- // This is either the first request ever for "target", or the heartbeat timeout has
- // passed, so we're starting a "new" heartbeat.
- hbStats.start(now);
- alreadyElapsed = Milliseconds(0);
- }
- ReplSetHeartbeatArgs hbArgs;
- hbArgs.setProtocolVersion(1);
- hbArgs.setCheckEmpty(false);
- if (_rsConfig.isInitialized()) {
- hbArgs.setSetName(_rsConfig.getReplSetName());
- hbArgs.setConfigVersion(_rsConfig.getConfigVersion());
- if (_selfIndex >= 0) {
- const MemberConfig& me = _selfConfig();
- hbArgs.setSenderHost(me.getHostAndPort());
- hbArgs.setSenderId(me.getId());
- }
- } else {
- hbArgs.setSetName(ourSetName);
- hbArgs.setConfigVersion(-2);
- }
- hbArgs.setHeartbeatVersion(1);
-
- const Milliseconds timeoutPeriod(
- _rsConfig.isInitialized() ? _rsConfig.getHeartbeatTimeoutPeriodMillis()
- : Milliseconds{ReplSetConfig::kDefaultHeartbeatTimeoutPeriod});
- const Milliseconds timeout = timeoutPeriod - alreadyElapsed;
- return std::make_pair(hbArgs, timeout);
-}
-
std::pair<ReplSetHeartbeatArgsV1, Milliseconds> TopologyCoordinator::prepareHeartbeatRequestV1(
Date_t now, const std::string& ourSetName, const HostAndPort& target) {
PingStats& hbStats = _pings[target];
diff --git a/src/mongo/db/repl/topology_coordinator.h b/src/mongo/db/repl/topology_coordinator.h
index 60ac2f83179..da11d840e7d 100644
--- a/src/mongo/db/repl/topology_coordinator.h
+++ b/src/mongo/db/repl/topology_coordinator.h
@@ -48,7 +48,6 @@ namespace repl {
class HeartbeatResponseAction;
class MemberData;
class OpTime;
-class ReplSetHeartbeatArgs;
class ReplSetConfig;
class TagSubgroup;
struct MemberState;
@@ -338,12 +337,6 @@ public:
BSONObjBuilder* response,
Status* result);
- // produce a reply to a heartbeat
- Status prepareHeartbeatResponse(Date_t now,
- const ReplSetHeartbeatArgs& args,
- const std::string& ourSetName,
- ReplSetHeartbeatResponse* response);
-
// produce a reply to a V1 heartbeat
Status prepareHeartbeatResponseV1(Date_t now,
const ReplSetHeartbeatArgsV1& args,
@@ -418,8 +411,6 @@ public:
* This call should be paired (with intervening network communication) with a call to
* processHeartbeatResponse for the same "target".
*/
- std::pair<ReplSetHeartbeatArgs, Milliseconds> prepareHeartbeatRequest(
- Date_t now, const std::string& ourSetName, const HostAndPort& target);
std::pair<ReplSetHeartbeatArgsV1, Milliseconds> prepareHeartbeatRequestV1(
Date_t now, const std::string& ourSetName, const HostAndPort& target);
@@ -448,7 +439,7 @@ public:
* processWinElection) before calling updateConfig.
*
* This call should be paired (with intervening network communication) with a call to
- * prepareHeartbeatRequest for the same "target".
+ * prepareHeartbeatRequestV1 for the same "target".
*/
HeartbeatResponseAction processHeartbeatResponse(
Date_t now,
diff --git a/src/mongo/db/repl/topology_coordinator_v1_test.cpp b/src/mongo/db/repl/topology_coordinator_v1_test.cpp
index 1cdff1562fe..27b9cdbd014 100644
--- a/src/mongo/db/repl/topology_coordinator_v1_test.cpp
+++ b/src/mongo/db/repl/topology_coordinator_v1_test.cpp
@@ -32,7 +32,6 @@
#include "mongo/bson/json.h"
#include "mongo/db/repl/heartbeat_response_action.h"
-#include "mongo/db/repl/repl_set_heartbeat_args.h"
#include "mongo/db/repl/repl_set_heartbeat_args_v1.h"
#include "mongo/db/repl/repl_set_heartbeat_response.h"
#include "mongo/db/repl/repl_set_request_votes_args.h"
diff --git a/src/mongo/embedded/replication_coordinator_embedded.cpp b/src/mongo/embedded/replication_coordinator_embedded.cpp
index 8ecc3fe8ee5..c9be1cbde04 100644
--- a/src/mongo/embedded/replication_coordinator_embedded.cpp
+++ b/src/mongo/embedded/replication_coordinator_embedded.cpp
@@ -289,11 +289,6 @@ Status ReplicationCoordinatorEmbedded::processReplSetFreeze(int, BSONObjBuilder*
UASSERT_NOT_IMPLEMENTED;
}
-Status ReplicationCoordinatorEmbedded::processHeartbeat(const ReplSetHeartbeatArgs&,
- ReplSetHeartbeatResponse*) {
- UASSERT_NOT_IMPLEMENTED;
-}
-
Status ReplicationCoordinatorEmbedded::processReplSetReconfig(OperationContext*,
const ReplSetReconfigArgs&,
BSONObjBuilder*) {
diff --git a/src/mongo/embedded/replication_coordinator_embedded.h b/src/mongo/embedded/replication_coordinator_embedded.h
index c30cb6a77c8..21f84afee1f 100644
--- a/src/mongo/embedded/replication_coordinator_embedded.h
+++ b/src/mongo/embedded/replication_coordinator_embedded.h
@@ -160,9 +160,6 @@ public:
Status processReplSetFreeze(int, BSONObjBuilder*) override;
- Status processHeartbeat(const repl::ReplSetHeartbeatArgs&,
- repl::ReplSetHeartbeatResponse*) override;
-
Status processReplSetReconfig(OperationContext*,
const ReplSetReconfigArgs&,
BSONObjBuilder*) override;