diff options
author | Siyuan Zhou <siyuan.zhou@mongodb.com> | 2017-04-20 22:42:11 -0400 |
---|---|---|
committer | Siyuan Zhou <siyuan.zhou@mongodb.com> | 2017-06-16 13:59:29 -0400 |
commit | 133978ed116d3852bb1b8557cc8603b7f6045947 (patch) | |
tree | 835ec9e6a395de98871d17d6a95866635435e065 | |
parent | 7f509b09e3b17a4e6627fdbd9a46d12611745941 (diff) | |
download | mongo-133978ed116d3852bb1b8557cc8603b7f6045947.tar.gz |
SERVER-26848 Remove dead code of primary catch-up.
(cherry picked from commit e4f20f24ddbb9cea2255df6fe0cfd34ddeb0263e)
-rw-r--r-- | src/mongo/db/repl/SConscript | 17 | ||||
-rw-r--r-- | src/mongo/db/repl/freshness_scanner.cpp | 129 | ||||
-rw-r--r-- | src/mongo/db/repl/freshness_scanner.h | 117 | ||||
-rw-r--r-- | src/mongo/db/repl/freshness_scanner_test.cpp | 228 | ||||
-rw-r--r-- | src/mongo/db/repl/replication_coordinator_impl.cpp | 91 | ||||
-rw-r--r-- | src/mongo/db/repl/replication_coordinator_impl.h | 20 | ||||
-rw-r--r-- | src/mongo/db/repl/replication_coordinator_test_fixture.cpp | 4 |
7 files changed, 0 insertions, 606 deletions
diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript index 4d3bb811971..05dbeff18a0 100644 --- a/src/mongo/db/repl/SConscript +++ b/src/mongo/db/repl/SConscript @@ -401,7 +401,6 @@ env.Library('repl_coordinator_impl', 'check_quorum_for_config_change.cpp', 'elect_cmd_runner.cpp', 'freshness_checker.cpp', - 'freshness_scanner.cpp', 'repl_client_info.cpp', 'repl_set_config_checks.cpp', 'replication_coordinator_impl.cpp', @@ -1128,22 +1127,6 @@ env.CppUnitTest( ], ) - -env.CppUnitTest( - target='freshness_scanner_test', - source=[ - 'freshness_scanner_test.cpp', - ], - LIBDEPS=[ - 'repl_coordinator_impl', - 'replica_set_messages', - 'replmocks', - '$BUILD_DIR/mongo/db/auth/authorization_manager_mock_init', - '$BUILD_DIR/mongo/db/commands_test_crutch', - '$BUILD_DIR/mongo/db/service_context_noop_init', - ], -) - env.Library( target="serveronly", source=[ diff --git a/src/mongo/db/repl/freshness_scanner.cpp b/src/mongo/db/repl/freshness_scanner.cpp deleted file mode 100644 index f9de9409373..00000000000 --- a/src/mongo/db/repl/freshness_scanner.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/** - * Copyright 2016 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. - */ - -#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kReplication - -#include "mongo/platform/basic.h" - -#include "mongo/db/repl/freshness_scanner.h" - -#include "mongo/base/status.h" -#include "mongo/db/repl/bson_extract_optime.h" -#include "mongo/db/repl/optime.h" -#include "mongo/db/repl/replication_executor.h" -#include "mongo/db/repl/scatter_gather_runner.h" -#include "mongo/rpc/get_status_from_command_result.h" -#include "mongo/util/log.h" - -namespace mongo { -namespace repl { - -using executor::RemoteCommandRequest; - -FreshnessScanner::Algorithm::Algorithm(const ReplSetConfig& rsConfig, - int myIndex, - Milliseconds timeout) - : _rsConfig(rsConfig), _myIndex(myIndex), _timeout(timeout) { - for (int index = 0; index < _rsConfig.getNumMembers(); index++) { - if (index != _myIndex) { - _targets.push_back(_rsConfig.getMemberAt(index).getHostAndPort()); - } - } - _totalRequests = _targets.size(); -} - -std::vector<RemoteCommandRequest> FreshnessScanner::Algorithm::getRequests() const { - BSONObjBuilder cmdBuilder; - cmdBuilder << "replSetGetStatus" << 1; - const BSONObj getStatusCmd = cmdBuilder.obj(); - - std::vector<RemoteCommandRequest> requests; - for (auto& target : _targets) { - requests.push_back(RemoteCommandRequest(target, "admin", getStatusCmd, nullptr, _timeout)); - } - return requests; -} - -void FreshnessScanner::Algorithm::processResponse(const RemoteCommandRequest& request, - const ResponseStatus& response) { - _responsesProcessed++; - if (!response.isOK()) { // failed response - LOG(2) << "FreshnessScanner: Got failed response from " << request.target << ": " - << response.status; - } else { - BSONObj opTimesObj = response.data.getObjectField("optimes"); - OpTime lastOpTime; - Status status = bsonExtractOpTimeField(opTimesObj, "appliedOpTime", &lastOpTime); - if (!status.isOK()) { - LOG(2) << "FreshnessScanner: failed to parse opTime in " << opTimesObj << " from " - << request.target << causedBy(status); - return; - } - - int index = _rsConfig.findMemberIndexByHostAndPort(request.target); - FreshnessInfo freshnessInfo{index, lastOpTime}; - - auto cmp = [](const FreshnessInfo& a, const FreshnessInfo& b) { - return a.opTime > b.opTime; - }; - auto iter = - std::upper_bound(_freshnessInfos.begin(), _freshnessInfos.end(), freshnessInfo, cmp); - _freshnessInfos.insert(iter, freshnessInfo); - LOG(2) << "FreshnessScanner: processed response " << opTimesObj << " from " - << request.target; - } -} - -bool FreshnessScanner::Algorithm::hasReceivedSufficientResponses() const { - return _responsesProcessed == _totalRequests; -} - -FreshnessScanner::Result FreshnessScanner::Algorithm::getResult() const { - invariant(hasReceivedSufficientResponses()); - return _freshnessInfos; -} - -StatusWith<ReplicationExecutor::EventHandle> FreshnessScanner::start(ReplicationExecutor* executor, - const ReplSetConfig& rsConfig, - int myIndex, - Milliseconds timeout) { - _algorithm.reset(new Algorithm(rsConfig, myIndex, timeout)); - _runner.reset(new ScatterGatherRunner(_algorithm.get(), executor)); - return _runner->start(); -} - -void FreshnessScanner::cancel() { - _runner->cancel(); -} - -FreshnessScanner::Result FreshnessScanner::getResult() const { - return _algorithm->getResult(); -} - -} // namespace repl -} // namespace mongo diff --git a/src/mongo/db/repl/freshness_scanner.h b/src/mongo/db/repl/freshness_scanner.h deleted file mode 100644 index bc474b4fadd..00000000000 --- a/src/mongo/db/repl/freshness_scanner.h +++ /dev/null @@ -1,117 +0,0 @@ -/** - * Copyright (C) 2016 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 <memory> -#include <vector> - -#include "mongo/base/disallow_copying.h" -#include "mongo/bson/timestamp.h" -#include "mongo/db/repl/optime.h" -#include "mongo/db/repl/repl_set_config.h" -#include "mongo/db/repl/replication_executor.h" -#include "mongo/db/repl/scatter_gather_algorithm.h" -#include "mongo/db/repl/scatter_gather_runner.h" -#include "mongo/stdx/functional.h" - -namespace mongo { - -class Status; - -namespace repl { - -class ScatterGatherRunner; - -class FreshnessScanner { - MONGO_DISALLOW_COPYING(FreshnessScanner); - -public: - struct FreshnessInfo { - // The index of node in ReplSetConfig. - int index; - // The latest applied opTime on that node. - OpTime opTime; - }; - - using Result = std::vector<FreshnessInfo>; - - class Algorithm : public ScatterGatherAlgorithm { - public: - Algorithm(const ReplSetConfig& rsConfig, int myIndex, Milliseconds timeout); - virtual std::vector<executor::RemoteCommandRequest> getRequests() const; - virtual void processResponse(const executor::RemoteCommandRequest& request, - const ResponseStatus& response); - virtual bool hasReceivedSufficientResponses() const; - - /** - * Returns a sorted list of nodes in descending lastAppliedOptime order. - * - * It is invalid to call this before hasReceivedSufficientResponses returns true. - */ - Result getResult() const; - - private: - const ReplSetConfig _rsConfig; - std::vector<HostAndPort> _targets; - const int _myIndex; - const Milliseconds _timeout; - Result _freshnessInfos; - int _responsesProcessed = 0; - int _totalRequests = 0; - }; - - FreshnessScanner() = default; - virtual ~FreshnessScanner() = default; - - /** - * Begins the process of sending replSetGetFreshness commands to all nodes - * in currentConfig, in attempt to find the most up-to-date oplog. - * - * evh can be used to schedule a callback when the process is complete. - * If this function returns Status::OK(), evh is then guaranteed to be signaled. - **/ - StatusWith<ReplicationExecutor::EventHandle> start(ReplicationExecutor* executor, - const ReplSetConfig& rsConfig, - int myIndex, - Milliseconds timeout); - - /** - * Informs the FreshnessScanner to cancel further processing. - */ - void cancel(); - - Result getResult() const; - -private: - std::unique_ptr<Algorithm> _algorithm; - std::unique_ptr<ScatterGatherRunner> _runner; -}; - -} // namespace repl -} // namespace mongo diff --git a/src/mongo/db/repl/freshness_scanner_test.cpp b/src/mongo/db/repl/freshness_scanner_test.cpp deleted file mode 100644 index 7a4339e956a..00000000000 --- a/src/mongo/db/repl/freshness_scanner_test.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/** - * Copyright (C) 2016 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/base/status.h" -#include "mongo/db/jsobj.h" -#include "mongo/db/repl/freshness_scanner.h" -#include "mongo/db/repl/replication_coordinator_impl.h" -#include "mongo/db/repl/replication_executor.h" -#include "mongo/executor/network_interface_mock.h" -#include "mongo/stdx/functional.h" -#include "mongo/stdx/memory.h" -#include "mongo/stdx/thread.h" -#include "mongo/unittest/unittest.h" - -namespace mongo { -namespace repl { -namespace { - -using executor::NetworkInterfaceMock; -using executor::RemoteCommandRequest; -using executor::RemoteCommandResponse; -using unittest::assertGet; - -class FreshnessScannerTest : public mongo::unittest::Test { -public: - NetworkInterfaceMock* getNet() { - return _net; - } - ReplicationExecutor* getExecutor() { - return _executor.get(); - } - - virtual void setUp() { - ASSERT_OK(_config.initialize(BSON("_id" - << "rs0" - << "version" - << 1 - << "members" - << BSON_ARRAY(BSON("_id" << 0 << "host" - << "host0") - << BSON("_id" << 1 << "host" - << "host1") - << BSON("_id" << 2 << "host" - << "host2") - << BSON("_id" << 3 << "host" - << "host3" - << "votes" - << 0 - << "priority" - << 0) - << BSON("_id" << 4 << "host" - << "host4" - << "votes" - << 0 - << "priority" - << 0))))); - ASSERT_OK(_config.validate()); - - _net = new NetworkInterfaceMock; - _executor = stdx::make_unique<ReplicationExecutor>(_net, 1 /* prng seed */); - _executorThread = - stdx::make_unique<stdx::thread>(stdx::bind(&ReplicationExecutor::run, _executor.get())); - } - - virtual void tearDown() { - _executor->shutdown(); - _executorThread->join(); - } - -protected: - RemoteCommandRequest requestFrom(std::string hostname) { - return RemoteCommandRequest(HostAndPort(hostname), - "", // fields do not matter in FreshnessScanner - BSONObj(), - nullptr, - Milliseconds(0)); - } - - ResponseStatus makeResponseStatus(BSONObj response) { - return ResponseStatus( - NetworkInterfaceMock::Response(response, BSONObj(), Milliseconds(10))); - } - - ResponseStatus badResponseStatus() { - return ResponseStatus(ErrorCodes::NodeNotFound, "not on my watch"); - } - - ResponseStatus goodResponseStatus(Timestamp timestamp, long long term) { - // OpTime part of replSetGetStatus. - BSONObj response = - BSON("optimes" << BSON("appliedOpTime" << OpTime(timestamp, term).toBSON())); - return makeResponseStatus(response); - } - - ReplSetConfig _config; - -private: - // owned by _executor - NetworkInterfaceMock* _net; - std::unique_ptr<ReplicationExecutor> _executor; - std::unique_ptr<stdx::thread> _executorThread; -}; - -TEST_F(FreshnessScannerTest, ImmediateGoodResponse) { - FreshnessScanner::Algorithm algo(_config, 0, Milliseconds(2000)); - - ASSERT_FALSE(algo.hasReceivedSufficientResponses()); - algo.processResponse(requestFrom("host1"), goodResponseStatus(Timestamp(1, 100), 1)); - ASSERT_FALSE(algo.hasReceivedSufficientResponses()); - algo.processResponse(requestFrom("host2"), goodResponseStatus(Timestamp(1, 200), 1)); - ASSERT_FALSE(algo.hasReceivedSufficientResponses()); - algo.processResponse(requestFrom("host3"), goodResponseStatus(Timestamp(1, 400), 1)); - ASSERT_FALSE(algo.hasReceivedSufficientResponses()); - algo.processResponse(requestFrom("host4"), goodResponseStatus(Timestamp(1, 300), 1)); - ASSERT_TRUE(algo.hasReceivedSufficientResponses()); - ASSERT_EQUALS((size_t)4, algo.getResult().size()); - ASSERT_EQUALS(3, algo.getResult().front().index); - ASSERT_EQUALS(OpTime(Timestamp(1, 400), 1), algo.getResult().front().opTime); - ASSERT_EQUALS(1, algo.getResult().back().index); - ASSERT_EQUALS(OpTime(Timestamp(1, 100), 1), algo.getResult().back().opTime); -} - -TEST_F(FreshnessScannerTest, ImmediateBadResponse) { - FreshnessScanner::Algorithm algo(_config, 0, Milliseconds(2000)); - - // Cannot access host 1 and host 2. - ASSERT_FALSE(algo.hasReceivedSufficientResponses()); - algo.processResponse(requestFrom("host1"), badResponseStatus()); - ASSERT_FALSE(algo.hasReceivedSufficientResponses()); - algo.processResponse(requestFrom("host2"), badResponseStatus()); - ASSERT_FALSE(algo.hasReceivedSufficientResponses()); - - // host 3 is in an old version, which doesn't include OpTimes in the response. - algo.processResponse(requestFrom("host3"), makeResponseStatus(BSONObj())); - ASSERT_FALSE(algo.hasReceivedSufficientResponses()); - - // Responses from host 4 in PV0 are considered as bad responses. - auto response4 = BSON("optimes" << BSON("appliedOpTime" << Timestamp(1, 300))); - algo.processResponse(requestFrom("host4"), makeResponseStatus(response4)); - ASSERT_TRUE(algo.hasReceivedSufficientResponses()); - ASSERT_EQUALS((size_t)0, algo.getResult().size()); -} - -TEST_F(FreshnessScannerTest, AllResponsesTimeout) { - Milliseconds timeout(2000); - FreshnessScanner scanner; - scanner.start(getExecutor(), _config, 0, timeout); - - auto net = getNet(); - net->enterNetwork(); - ASSERT(net->hasReadyRequests()); - // Black hole all requests. - while (net->hasReadyRequests()) { - net->blackHole(net->getNextReadyRequest()); - } - auto later = net->now() + Milliseconds(2010); - ASSERT_EQ(later, net->runUntil(later)); - net->exitNetwork(); - ASSERT_EQUALS((size_t)0, scanner.getResult().size()); -} - - -TEST_F(FreshnessScannerTest, BadResponsesAndTimeout) { - Milliseconds timeout(2000); - FreshnessScanner scanner; - scanner.start(getExecutor(), _config, 0, timeout); - - auto net = getNet(); - net->enterNetwork(); - - Date_t later = net->now() + Milliseconds(10); - // host 1 returns good response. - ASSERT(net->hasReadyRequests()); - auto noi = net->getNextReadyRequest(); - HostAndPort successfulHost = noi->getRequest().target; - net->scheduleResponse(noi, later, goodResponseStatus(Timestamp(1, 100), 1)); - - // host 2 has a bad connection. - ASSERT(net->hasReadyRequests()); - net->scheduleResponse(net->getNextReadyRequest(), later, badResponseStatus()); - - // host 3 and 4 time out. - ASSERT(net->hasReadyRequests()); - net->blackHole(net->getNextReadyRequest()); - ASSERT(net->hasReadyRequests()); - net->blackHole(net->getNextReadyRequest()); - - // Advance the clock. - ASSERT(!net->hasReadyRequests()); - getNet()->runUntil(getNet()->now() + Milliseconds(2010)); - getNet()->exitNetwork(); - - ASSERT_EQUALS((size_t)1, scanner.getResult().size()); - auto freshnessInfo = scanner.getResult().front(); - ASSERT_EQUALS(_config.findMemberIndexByHostAndPort(successfulHost), freshnessInfo.index); - ASSERT_EQUALS(OpTime(Timestamp(1, 100), 1), freshnessInfo.opTime); -} - -} // namespace -} // namespace repl -} // namespace mongo diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp index 5e1ee6d886d..c3ada20f39b 100644 --- a/src/mongo/db/repl/replication_coordinator_impl.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl.cpp @@ -47,7 +47,6 @@ #include "mongo/db/repl/data_replicator_external_state_initial_sync.h" #include "mongo/db/repl/elect_cmd_runner.h" #include "mongo/db/repl/freshness_checker.h" -#include "mongo/db/repl/freshness_scanner.h" #include "mongo/db/repl/handshake_args.h" #include "mongo/db/repl/is_master_response.h" #include "mongo/db/repl/last_vote.h" @@ -2834,87 +2833,6 @@ Status ReplicationCoordinatorImpl::abortCatchupIfNeeded() { return Status(ErrorCodes::IllegalOperation, "The node is not in catch-up mode."); } -void ReplicationCoordinatorImpl::_scanOpTimeForCatchUp_inlock() { - auto scanner = std::make_shared<FreshnessScanner>(); - auto scanStartTime = _replExecutor.now(); - auto evhStatus = - scanner->start(&_replExecutor, _rsConfig, _selfIndex, _rsConfig.getCatchUpTimeoutPeriod()); - if (evhStatus == ErrorCodes::ShutdownInProgress) { - _enterDrainMode_inlock(); - return; - } - fassertStatusOK(40254, evhStatus.getStatus()); - long long term = _cachedTerm; - _replExecutor.onEvent( - evhStatus.getValue(), [this, scanner, scanStartTime, term](const CallbackArgs& cbData) { - LockGuard lk(_mutex); - if (cbData.status == ErrorCodes::CallbackCanceled) { - _enterDrainMode_inlock(); - return; - } - auto totalTimeout = _rsConfig.getCatchUpTimeoutPeriod(); - auto catchUpTimeout = totalTimeout - (_replExecutor.now() - scanStartTime); - _catchUpOplogToLatest_inlock(*scanner, catchUpTimeout, term); - }); -} - -void ReplicationCoordinatorImpl::_catchUpOplogToLatest_inlock(const FreshnessScanner& scanner, - Milliseconds timeout, - long long originalTerm) { - // On stepping down, the node doesn't update its term immediately due to SERVER-21425. - // Term is also checked in case the catchup timeout is so long that the node becomes primary - // again. - if (!_memberState.primary() || originalTerm != _cachedTerm) { - // If the node steps down during the catch-up, we don't go into drain mode. - log() << "Stopped transition to primary of term " << originalTerm - << " because I've already stepped down."; - return; - } - - auto result = scanner.getResult(); - - // Cannot access any nodes within timeout. - if (result.size() == 0) { - log() << "Could not access any nodes within timeout when checking for " - << "additional ops to apply before finishing transition to primary. " - << "Will move forward with becoming primary anyway."; - _enterDrainMode_inlock(); - return; - } - - // I'm most up-to-date as far as I know. - auto freshnessInfo = result.front(); - if (freshnessInfo.opTime <= _getMyLastAppliedOpTime_inlock()) { - log() << "My optime is most up-to-date, skipping catch-up " - << "and completing transition to primary."; - _enterDrainMode_inlock(); - return; - } - - // Wait for the replication level to reach the latest opTime within timeout. - auto latestOpTime = freshnessInfo.opTime; - auto finishCB = [this, latestOpTime]() { - if (latestOpTime > _getMyLastAppliedOpTime_inlock()) { - log() << "Cannot catch up oplog after becoming primary."; - } else { - log() << "Finished catch-up oplog after becoming primary."; - } - - _enterDrainMode_inlock(); - }; - auto waiterInfo = std::make_shared<CallbackWaiter>(freshnessInfo.opTime, finishCB); - - _opTimeWaiterList.add_inlock(waiterInfo.get()); - auto timeoutCB = [this, waiterInfo, finishCB](const CallbackArgs& cbData) { - LockGuard lk(_mutex); - if (_opTimeWaiterList.remove_inlock(waiterInfo.get())) { - finishCB(); - } - }; - // Schedule the timeout callback. It may signal after we have already caught up. - _replExecutor.scheduleWorkAt(_replExecutor.now() + timeout, timeoutCB); -} - void ReplicationCoordinatorImpl::_enterDrainMode_inlock() { _applierState = ApplierState::Draining; _externalState->stopProducer(); @@ -3769,15 +3687,6 @@ EventHandle ReplicationCoordinatorImpl::_makeEvent() { return eventResult.getValue(); } -void ReplicationCoordinatorImpl::_scheduleElectionWinNotification() { - stdx::lock_guard<stdx::mutex> lock(_mutex); - if (!_getMemberState_inlock().primary()) { - return; - } - - _restartHeartbeats_inlock(); -} - WriteConcernOptions ReplicationCoordinatorImpl::populateUnsetWriteConcernOptionsSyncMode( WriteConcernOptions wc) { WriteConcernOptions writeConcern(wc); diff --git a/src/mongo/db/repl/replication_coordinator_impl.h b/src/mongo/db/repl/replication_coordinator_impl.h index cc72381f746..f49dab72608 100644 --- a/src/mongo/db/repl/replication_coordinator_impl.h +++ b/src/mongo/db/repl/replication_coordinator_impl.h @@ -73,7 +73,6 @@ namespace repl { class ElectCmdRunner; class FreshnessChecker; -class FreshnessScanner; class HandshakeArgs; class HeartbeatResponseAction; class LastVote; @@ -1210,31 +1209,12 @@ private: EventHandle _makeEvent(); /** - * Schedule notification of election win. - */ - void _scheduleElectionWinNotification(); - - /** * Wrap a function into executor callback. * If the callback is cancelled, the given function won't run. */ executor::TaskExecutor::CallbackFn _wrapAsCallbackFn(const stdx::function<void()>& work); /** - * Scan all nodes to find out the the latest optime in the replset, thus we know when there's no - * more to catch up before the timeout. It also schedules the actual catch-up once we get the - * response from the freshness scan. - */ - void _scanOpTimeForCatchUp_inlock(); - /** - * Wait for data replication until we reach the latest optime, or the timeout expires. - * "originalTerm" is the term when catch-up work is scheduled and used to detect - * the step-down (and potential following step-up) after catch-up gets scheduled. - */ - void _catchUpOplogToLatest_inlock(const FreshnessScanner& scanner, - Milliseconds timeout, - long long originalTerm); - /** * Finish catch-up mode and start drain mode. */ void _enterDrainMode_inlock(); diff --git a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp index 8c5b821b5b6..fd946de9e88 100644 --- a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp +++ b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp @@ -327,10 +327,6 @@ void ReplCoordTest::simulateSuccessfulV1ElectionAt(Date_t electionTime) { << request.cmdObj["term"].Long() << "voteGranted" << true))); - } else if (request.cmdObj.firstElement().fieldNameStringData() == "replSetGetStatus") { - // OpTime part of replSetGetStatus for use by FreshnessScanner during catch-up period. - BSONObj response = BSON("optimes" << BSON("appliedOpTime" << OpTime().toBSON())); - net->scheduleResponse(noi, net->now(), makeResponseStatus(response)); } else { error() << "Black holing unexpected request to " << request.target << ": " << request.cmdObj; |