diff options
Diffstat (limited to 'src/mongo/db/repl')
25 files changed, 25 insertions, 542 deletions
diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript index 4fc00aa268e..d09428bf75d 100644 --- a/src/mongo/db/repl/SConscript +++ b/src/mongo/db/repl/SConscript @@ -990,7 +990,6 @@ env.Library('read_concern_args', env.Library('replica_set_messages', [ - 'handshake_args.cpp', 'is_master_response.cpp', 'member_config.cpp', 'repl_set_config.cpp', diff --git a/src/mongo/db/repl/apply_ops.cpp b/src/mongo/db/repl/apply_ops.cpp index 2d85fe4c908..ce59247fabb 100644 --- a/src/mongo/db/repl/apply_ops.cpp +++ b/src/mongo/db/repl/apply_ops.cpp @@ -443,8 +443,7 @@ Status applyOps(OperationContext* opCtx, writeConflictRetry(opCtx, "applyOps", dbName, [&] { BSONObjBuilder intermediateResult; std::unique_ptr<BSONArrayBuilder> opsBuilder; - if (opCtx->writesAreReplicated() && - repl::ReplicationCoordinator::modeMasterSlave != replCoord->getReplicationMode()) { + if (opCtx->writesAreReplicated()) { opsBuilder = stdx::make_unique<BSONArrayBuilder>(); } WriteUnitOfWork wunit(opCtx); diff --git a/src/mongo/db/repl/handshake_args.cpp b/src/mongo/db/repl/handshake_args.cpp deleted file mode 100644 index d8ebf3c0fc7..00000000000 --- a/src/mongo/db/repl/handshake_args.cpp +++ /dev/null @@ -1,105 +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/handshake_args.h" - -#include "mongo/base/status.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 kRIDFieldName = "handshake"; -// TODO(danneberg) remove after 3.0 since this field is only allowed for backwards compatibility -const std::string kOldMemberConfigFieldName = "config"; -const std::string kMemberIdFieldName = "member"; - -const std::string kLegalHandshakeFieldNames[] = { - kRIDFieldName, kOldMemberConfigFieldName, kMemberIdFieldName}; - -} // namespace - -HandshakeArgs::HandshakeArgs() : _hasRid(false), _hasMemberId(false), _rid(OID()), _memberId(-1) {} - -Status HandshakeArgs::initialize(const BSONObj& argsObj) { - Status status = - bsonCheckOnlyHasFieldsForCommand("HandshakeArgs", argsObj, kLegalHandshakeFieldNames); - if (!status.isOK()) - return status; - - BSONElement oid; - status = bsonExtractTypedField(argsObj, kRIDFieldName, jstOID, &oid); - if (!status.isOK()) - return status; - _rid = oid.OID(); - _hasRid = true; - - status = bsonExtractIntegerField(argsObj, kMemberIdFieldName, &_memberId); - if (!status.isOK()) { - // field not necessary for master slave, do not return NoSuchKey Error - if (status != ErrorCodes::NoSuchKey) { - return status; - } - _memberId = -1; - } else { - _hasMemberId = true; - } - - return Status::OK(); -} - -bool HandshakeArgs::isInitialized() const { - return _hasRid; -} - -void HandshakeArgs::setRid(const OID& newVal) { - _rid = newVal; - _hasRid = true; -} - -void HandshakeArgs::setMemberId(long long newVal) { - _memberId = newVal; - _hasMemberId = true; -} - -BSONObj HandshakeArgs::toBSON() const { - invariant(isInitialized()); - BSONObjBuilder builder; - builder.append(kRIDFieldName, _rid); - builder.append(kMemberIdFieldName, _memberId); - return builder.obj(); -} - -} // namespace repl -} // namespace mongo diff --git a/src/mongo/db/repl/handshake_args.h b/src/mongo/db/repl/handshake_args.h deleted file mode 100644 index b83bef87842..00000000000 --- a/src/mongo/db/repl/handshake_args.h +++ /dev/null @@ -1,103 +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 "mongo/db/jsobj.h" - -namespace mongo { - -class Status; - -namespace repl { - -/** - * Arguments to the handshake command. - */ -class HandshakeArgs { -public: - HandshakeArgs(); - - /** - * Initializes this HandshakeArgs from the contents of args. - */ - Status initialize(const BSONObj& argsObj); - - /** - * Returns true if all required fields have been initialized. - */ - bool isInitialized() const; - - /** - * Gets the _id of the sender in their ReplSetConfig. - */ - long long getMemberId() const { - return _memberId; - } - - /** - * Gets the unique identifier of the sender, which is used to track replication progress. - */ - OID getRid() const { - return _rid; - } - - /** - * The below methods check whether or not value in the method name has been set. - */ - bool hasRid() { - return _hasRid; - }; - bool hasMemberId() { - return _hasMemberId; - }; - - /** - * The below methods set the value in the method name to 'newVal'. - */ - void setRid(const OID& newVal); - void setMemberId(long long 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 _hasRid; - bool _hasMemberId; - - // look at the body of the isInitialized() function to see which fields are mandatory - OID _rid; - long long _memberId; -}; - -} // namespace repl -} // namespace mongo diff --git a/src/mongo/db/repl/member_data.cpp b/src/mongo/db/repl/member_data.cpp index c59eb1c6ce6..0ea383532b0 100644 --- a/src/mongo/db/repl/member_data.cpp +++ b/src/mongo/db/repl/member_data.cpp @@ -135,8 +135,8 @@ void MemberData::setLastDurableOpTime(OpTime opTime, Date_t now) { log() << "Durable progress (" << opTime << ") is ahead of the applied progress (" << _lastAppliedOpTime << ". This is likely due to a " "rollback." - << " memberid: " << _memberId << " rid: " << _rid << " host " - << _hostAndPort.toString() << " previous durable progress: " << _lastDurableOpTime; + << " memberid: " << _memberId << _hostAndPort.toString() + << " previous durable progress: " << _lastDurableOpTime; } else { _lastDurableOpTime = opTime; } diff --git a/src/mongo/db/repl/member_data.h b/src/mongo/db/repl/member_data.h index 9a1d56c0c5c..ab484a64469 100644 --- a/src/mongo/db/repl/member_data.h +++ b/src/mongo/db/repl/member_data.h @@ -131,10 +131,6 @@ public: return _memberId; } - OID getRid() const { - return _rid; - } - bool isSelf() const { return _isSelf; } @@ -229,10 +225,6 @@ public: _memberId = memberId; } - void setRid(OID rid) { - _rid = rid; - } - private: // -1 = not checked yet, 0 = member is down/unreachable, 1 = member is up int _health; @@ -275,11 +267,8 @@ private: // Is this the data for this member? bool _isSelf; - // This member's RID, used only in master/slave replication. - OID _rid; - // This member's member ID. memberId and hostAndPort duplicate information in the - // configuration for replica sets, but are required to be here for master/slave replication. + // set's ReplSetConfig. int _memberId = -1; // Client address of this member. diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp index eba01f1076c..ec622e6ff1b 100644 --- a/src/mongo/db/repl/oplog.cpp +++ b/src/mongo/db/repl/oplog.cpp @@ -111,8 +111,6 @@ using std::vector; using IndexVersion = IndexDescriptor::IndexVersion; namespace repl { -std::string masterSlaveOplogName = "local.oplog.$main"; - namespace { /** * The `_localOplogCollection` pointer is always valid (or null) because an @@ -163,13 +161,9 @@ void _getNextOpTimes(OperationContext* opCtx, fassert(28560, oplog->getRecordStore()->oplogDiskLocRegister(opCtx, ts)); - // Set hash if we're in replset mode, otherwise it remains 0 in master/slave. - const bool needHash = (replCoord->getReplicationMode() == ReplicationCoordinator::modeReplSet); for (std::size_t i = 0; i < count; i++) { slotsOut[i].opTime = {Timestamp(ts.asULL() + i), term}; - if (needHash) { - slotsOut[i].hash = hashGenerator.nextInt64(); - } + slotsOut[i].hash = hashGenerator.nextInt64(); } } @@ -218,14 +212,9 @@ void setOplogCollectionName(ServiceContext* service) { case ReplicationCoordinator::modeReplSet: _oplogCollectionName = NamespaceString::kRsOplogNamespace.ns(); break; - case ReplicationCoordinator::modeMasterSlave: - _oplogCollectionName = masterSlaveOplogName; - break; case ReplicationCoordinator::modeNone: // leave empty. break; - default: - MONGO_UNREACHABLE; } } @@ -332,9 +321,7 @@ OplogDocWriter _logOpWriter(OperationContext* opCtx, b.append("v", OplogEntry::kOplogVersion); b.append("op", opstr); b.append("ns", nss.ns()); - if (uuid && - ReplicationCoordinator::get(opCtx)->getReplicationMode() != - ReplicationCoordinator::modeMasterSlave) + if (uuid) uuid->appendToBuilder(&b, "ui"); if (fromMigrate) @@ -361,7 +348,6 @@ OplogDocWriter _logOpWriter(OperationContext* opCtx, "u" update "d" delete "c" db cmd - "db" declares presence of a database (ns is set to the db name + '.') (master/slave only) "n" no op */ @@ -370,8 +356,7 @@ OplogDocWriter _logOpWriter(OperationContext* opCtx, * writers - an array with size nDocs of DocWriter objects. * timestamps - an array with size nDocs of respective Timestamp objects for each DocWriter. * oplogCollection - collection to be written to. - * replicationMode - ReplSet or MasterSlave. - * finalOpTime - the OpTime of the last DocWriter object. + * finalOpTime - the OpTime of the last DocWriter object. */ void _logOpsInner(OperationContext* opCtx, const NamespaceString& nss, @@ -1139,10 +1124,6 @@ Status applyOperation_inlock(OperationContext* opCtx, // We do not assign timestamps on standalones. return false; } - case ReplicationCoordinator::modeMasterSlave: { - // Master-slave does not support timestamps so we do not assign a timestamp. - return false; - } } } return true; @@ -1549,10 +1530,6 @@ Status applyCommand_inlock(OperationContext* opCtx, // We do not assign timestamps on standalones. return false; } - case ReplicationCoordinator::modeMasterSlave: { - // Master-slave does not support timestamps so we do not assign a timestamp. - return false; - } } MONGO_UNREACHABLE; } @@ -1605,11 +1582,7 @@ Status applyCommand_inlock(OperationContext* opCtx, break; } default: - if (_oplogCollectionName == masterSlaveOplogName) { - error() << "Failed command " << redact(o) << " on " << nss.db() - << " with status " << status << " during oplog application"; - } else if (curOpToApply.acceptableErrors.find(status.code()) == - curOpToApply.acceptableErrors.end()) { + if (!curOpToApply.acceptableErrors.count(status.code())) { error() << "Failed command " << redact(o) << " on " << nss.db() << " with status " << status << " during oplog application"; return status; diff --git a/src/mongo/db/repl/oplog.h b/src/mongo/db/repl/oplog.h index 1120b96c152..3658bb8bbb0 100644 --- a/src/mongo/db/repl/oplog.h +++ b/src/mongo/db/repl/oplog.h @@ -95,10 +95,6 @@ void createOplog(OperationContext* opCtx, const std::string& oplogCollectionName */ void createOplog(OperationContext* opCtx); -extern std::string masterSlaveOplogName; - -extern int OPLOG_VERSION; - /** * Log insert(s) to the local oplog. * Returns the OpTime of every insert. diff --git a/src/mongo/db/repl/oplogreader.cpp b/src/mongo/db/repl/oplogreader.cpp index 9f5f01021bf..b65de6946ed 100644 --- a/src/mongo/db/repl/oplogreader.cpp +++ b/src/mongo/db/repl/oplogreader.cpp @@ -66,9 +66,6 @@ OplogReader::OplogReader() { /* TODO: slaveOk maybe shouldn't use? */ _tailingQueryOptions |= QueryOption_AwaitData; - - // Currently find command doesn't do the cursor tracking that master-slave relies on. - _tailingQueryOptions |= DBClientCursor::QueryOptionLocal_forceOpQuery; } bool OplogReader::connect(const HostAndPort& host) { diff --git a/src/mongo/db/repl/oplogreader.h b/src/mongo/db/repl/oplogreader.h index 92e224a6498..335771de867 100644 --- a/src/mongo/db/repl/oplogreader.h +++ b/src/mongo/db/repl/oplogreader.h @@ -109,17 +109,6 @@ public: BSONObj nextSafe() { return cursor->nextSafe(); } - - // master/slave only - void peek(std::vector<BSONObj>& v, int n) { - if (cursor.get()) - cursor->peek(v, n); - } - - // master/slave only - void putBack(BSONObj op) { - cursor->putBack(op); - } }; } // namespace repl diff --git a/src/mongo/db/repl/repl_client_info.h b/src/mongo/db/repl/repl_client_info.h index 09fc70f5a42..d27d7bd370b 100644 --- a/src/mongo/db/repl/repl_client_info.h +++ b/src/mongo/db/repl/repl_client_info.h @@ -56,14 +56,6 @@ public: _lastOp = OpTime(); } - // Only used for master/slave - void setRemoteID(OID rid) { - _remoteId = rid; - } - OID getRemoteID() const { - return _remoteId; - } - /** * Use this to set the LastOp to the latest known OpTime in the oplog. * This is necessary when doing no-op writes, as we need to set the client's lastOp to a proper @@ -75,7 +67,6 @@ private: static const long long kUninitializedTerm = -1; OpTime _lastOp = OpTime(); - OID _remoteId = OID(); }; } // namespace repl diff --git a/src/mongo/db/repl/replication_coordinator.h b/src/mongo/db/repl/replication_coordinator.h index 96be0d7be59..f43c285807c 100644 --- a/src/mongo/db/repl/replication_coordinator.h +++ b/src/mongo/db/repl/replication_coordinator.h @@ -65,7 +65,6 @@ class ReplSetMetadata; namespace repl { class BackgroundSync; -class HandshakeArgs; class IsMasterResponse; class OplogReader; class OpTime; @@ -124,17 +123,16 @@ public: */ virtual const ReplSettings& getSettings() const = 0; - enum Mode { modeNone = 0, modeReplSet, modeMasterSlave }; + enum Mode { modeNone = 0, modeReplSet }; /** - * Returns a value indicating whether this node was configured at start-up to run - * standalone, as part of a master-slave pair, or as a member of a replica set. + * Returns a value indicating whether this node was configured at start-up to run standalone or + * as a member of a replica set. */ virtual Mode getReplicationMode() const = 0; /** - * Returns true if this node is configured to be a member of a replica set or master/slave - * setup. + * Returns true if this node is configured to be a member of a replica set. */ virtual bool isReplEnabled() const = 0; @@ -209,9 +207,8 @@ public: virtual bool isMasterForReportingPurposes() = 0; /** - * Returns true if it is valid for this node to accept writes on the given database. - * Currently this is true only if this node is Primary, master in master/slave, - * a standalone, or is writing to the local database. + * Returns true if it is valid for this node to accept writes on the given database. Currently + * this is true only if this node is Primary, a standalone, or is writing to the local database. * * If a node was started with the replSet argument, but has not yet received a config, it * will not be able to receive writes to a database other than local (it will not be @@ -282,12 +279,6 @@ public: const NamespaceString& ns) = 0; /** - * Updates our internal tracking of the last OpTime applied for the given slave - * identified by "rid". Only valid to call in master/slave mode - */ - virtual Status setLastOptimeForSlave(const OID& rid, const Timestamp& ts) = 0; - - /** * Updates our internal tracking of the last OpTime applied to this node. * * The new value of "opTime" must be no less than any prior value passed to this method, and @@ -388,12 +379,6 @@ public: virtual OID getElectionId() = 0; /** - * Returns the RID for this node. The RID is used to identify this node to our sync source - * when sending updates about our replication progress. - */ - virtual OID getMyRID() const = 0; - - /** * Returns the id for this node as specified in the current replica set configuration. */ virtual int getMyId() const = 0; @@ -525,7 +510,7 @@ public: /** * Handles an incoming isMaster command for a replica set node. Should not be - * called on a master-slave or standalone node. + * called on a standalone node. */ virtual void fillIsMasterForReplSet(IsMasterResponse* result) = 0; @@ -681,16 +666,6 @@ public: long long* configVersion) = 0; /** - * Handles an incoming Handshake command. Associates the node's 'remoteID' with its - * 'handshake' object. This association is used to update internal representation of - * replication progress and to forward the node's replication progress upstream when this - * node is being chained through in master/slave replication. - * - * Returns ErrorCodes::IllegalOperation if we're not running with master/slave replication. - */ - virtual Status processHandshake(OperationContext* opCtx, const HandshakeArgs& handshake) = 0; - - /** * Returns a bool indicating whether or not this node builds indexes. */ virtual bool buildsIndexes() = 0; diff --git a/src/mongo/db/repl/replication_coordinator_external_state.h b/src/mongo/db/repl/replication_coordinator_external_state.h index 38697e94c1c..5ad47f2cbcb 100644 --- a/src/mongo/db/repl/replication_coordinator_external_state.h +++ b/src/mongo/db/repl/replication_coordinator_external_state.h @@ -85,8 +85,6 @@ public: /** * Starts steady state sync for replica set member. - * - * NOTE: Use either this or the Master/Slave version, but not both. */ virtual void startSteadyStateReplication(OperationContext* opCtx, ReplicationCoordinator* replCoord) = 0; @@ -160,14 +158,6 @@ public: virtual void forwardSlaveProgress() = 0; /** - * Queries the singleton document in local.me. If it exists and our hostname has not - * changed since we wrote, returns the RID stored in the object. If the document does not - * exist or our hostname doesn't match what was recorded in local.me, generates a new OID - * to use as our RID, stores it in local.me, and returns it. - */ - virtual OID ensureMe(OperationContext*) = 0; - - /** * Returns true if "host" is one of the network identities of this node. */ virtual bool isSelf(const HostAndPort& host, ServiceContext* service) = 0; diff --git a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp index d5baf0d959b..79195384543 100644 --- a/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp +++ b/src/mongo/db/repl/replication_coordinator_external_state_impl.cpp @@ -490,34 +490,6 @@ void ReplicationCoordinatorExternalStateImpl::forwardSlaveProgress() { _syncSourceFeedback.forwardSlaveProgress(); } -OID ReplicationCoordinatorExternalStateImpl::ensureMe(OperationContext* opCtx) { - std::string myname = getHostName(); - OID myRID; - { - Lock::DBLock lock(opCtx, meDatabaseName, MODE_X); - - BSONObj me; - // local.me is an identifier for a server for getLastError w:2+ - // TODO: handle WriteConflictExceptions below - if (!Helpers::getSingleton(opCtx, meCollectionName, me) || !me.hasField("host") || - me["host"].String() != myname) { - myRID = OID::gen(); - - // clean out local.me - Helpers::emptyCollection(opCtx, NamespaceString(meCollectionName)); - - // repopulate - BSONObjBuilder b; - b.append("_id", myRID); - b.append("host", myname); - Helpers::putSingleton(opCtx, meCollectionName, b.done()); - } else { - myRID = me["_id"].OID(); - } - } - return myRID; -} - StatusWith<BSONObj> ReplicationCoordinatorExternalStateImpl::loadLocalConfigDocument( OperationContext* opCtx) { try { diff --git a/src/mongo/db/repl/replication_coordinator_external_state_impl.h b/src/mongo/db/repl/replication_coordinator_external_state_impl.h index 3d124a24ef2..b3ed7827dde 100644 --- a/src/mongo/db/repl/replication_coordinator_external_state_impl.h +++ b/src/mongo/db/repl/replication_coordinator_external_state_impl.h @@ -83,7 +83,6 @@ public: void onDrainComplete(OperationContext* opCtx) override; OpTime onTransitionToPrimary(OperationContext* opCtx, bool isV1ElectionProtocol) override; virtual void forwardSlaveProgress(); - virtual OID ensureMe(OperationContext* opCtx); virtual bool isSelf(const HostAndPort& host, ServiceContext* service); virtual StatusWith<BSONObj> loadLocalConfigDocument(OperationContext* opCtx); virtual Status storeLocalConfigDocument(OperationContext* opCtx, const BSONObj& config); diff --git a/src/mongo/db/repl/replication_coordinator_external_state_mock.cpp b/src/mongo/db/repl/replication_coordinator_external_state_mock.cpp index 5f88d85e0ec..f6c0104283f 100644 --- a/src/mongo/db/repl/replication_coordinator_external_state_mock.cpp +++ b/src/mongo/db/repl/replication_coordinator_external_state_mock.cpp @@ -96,10 +96,6 @@ ThreadPool* ReplicationCoordinatorExternalStateMock::getDbWorkThreadPool() const void ReplicationCoordinatorExternalStateMock::forwardSlaveProgress() {} -OID ReplicationCoordinatorExternalStateMock::ensureMe(OperationContext*) { - return OID::gen(); -} - bool ReplicationCoordinatorExternalStateMock::isSelf(const HostAndPort& host, ServiceContext* const service) { return sequenceContains(_selfHosts, host); diff --git a/src/mongo/db/repl/replication_coordinator_external_state_mock.h b/src/mongo/db/repl/replication_coordinator_external_state_mock.h index 2d7f5563bba..c45fd82329d 100644 --- a/src/mongo/db/repl/replication_coordinator_external_state_mock.h +++ b/src/mongo/db/repl/replication_coordinator_external_state_mock.h @@ -71,7 +71,6 @@ public: void onDrainComplete(OperationContext* opCtx) override; OpTime onTransitionToPrimary(OperationContext* opCtx, bool isV1ElectionProtocol) override; virtual void forwardSlaveProgress(); - virtual OID ensureMe(OperationContext*); virtual bool isSelf(const HostAndPort& host, ServiceContext* service); virtual HostAndPort getClientHostAndPort(const OperationContext* opCtx); virtual StatusWith<BSONObj> loadLocalConfigDocument(OperationContext* opCtx); diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp index a9106e56cf5..cef2f6d9e2c 100644 --- a/src/mongo/db/repl/replication_coordinator_impl.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl.cpp @@ -48,7 +48,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/handshake_args.h" #include "mongo/db/repl/is_master_response.h" #include "mongo/db/repl/last_vote.h" #include "mongo/db/repl/read_concern_args.h" @@ -736,23 +735,15 @@ void ReplicationCoordinatorImpl::startup(OperationContext* opCtx) { invariant(_settings.usingReplSets()); { - OID rid = _externalState->ensureMe(opCtx); - stdx::lock_guard<stdx::mutex> lk(_mutex); fassert(18822, !_inShutdown); _setConfigState_inlock(kConfigStartingUp); - _myRID = rid; - _topCoord->setMyRid(rid); - } - - _replExecutor->startup(); - - { - stdx::lock_guard<stdx::mutex> lk(_mutex); _topCoord->setStorageEngineSupportsReadCommitted( _externalState->isReadCommittedSupportedByStorageEngine(opCtx)); } + _replExecutor->startup(); + bool doneLoadingConfig = _startLoadLocalConfig(opCtx); if (doneLoadingConfig) { // If we're not done loading the config, then the config state will be set by @@ -1015,16 +1006,6 @@ void ReplicationCoordinatorImpl::signalUpstreamUpdater() { _externalState->forwardSlaveProgress(); } -Status ReplicationCoordinatorImpl::setLastOptimeForSlave(const OID& rid, const Timestamp& ts) { - stdx::unique_lock<stdx::mutex> lock(_mutex); - - // term == -1 for master-slave - OpTime opTime(ts, OpTime::kUninitializedTerm); - _topCoord->setLastOptimeForSlave(rid, opTime, _replExecutor->now()); - _updateLastCommittedOpTime_inlock(); - return Status::OK(); -} - void ReplicationCoordinatorImpl::setMyHeartbeatMessage(const std::string& msg) { stdx::unique_lock<stdx::mutex> lock(_mutex); _topCoord->setMyHeartbeatMessage(_replExecutor->now(), msg); @@ -1462,11 +1443,6 @@ Status ReplicationCoordinatorImpl::_awaitReplication_inlock( return Status::OK(); } - if (replMode == modeMasterSlave && writeConcern.wMode == WriteConcernOptions::kMajority) { - // with master/slave, majority is equivalent to w=1 - return Status::OK(); - } - if (opTime.isNull()) { // If waiting for the empty optime, always say it's been replicated. return Status::OK(); @@ -1838,9 +1814,6 @@ Status ReplicationCoordinatorImpl::checkCanServeReadsFor_UNSAFE(OperationContext if (canAcceptWritesFor_UNSAFE(opCtx, ns)) { return Status::OK(); } - if (getReplicationMode() == modeMasterSlave) { - return Status::OK(); - } if (slaveOk) { if (isPrimaryOrSecondary) { return Status::OK(); @@ -1865,15 +1838,6 @@ OID ReplicationCoordinatorImpl::getElectionId() { return _electionId; } -OID ReplicationCoordinatorImpl::getMyRID() const { - stdx::lock_guard<stdx::mutex> lock(_mutex); - return _getMyRID_inlock(); -} - -OID ReplicationCoordinatorImpl::_getMyRID_inlock() const { - return _myRID; -} - int ReplicationCoordinatorImpl::getMyId() const { stdx::lock_guard<stdx::mutex> lock(_mutex); return _getMyId_inlock(); @@ -2834,14 +2798,6 @@ Status ReplicationCoordinatorImpl::processReplSetUpdatePosition(const UpdatePosi return status; } -Status ReplicationCoordinatorImpl::processHandshake(OperationContext* opCtx, - const HandshakeArgs& handshake) { - LOG(2) << "Received handshake " << handshake.toBSON(); - stdx::lock_guard<stdx::mutex> lock(_mutex); - return _topCoord->processHandshake(handshake.getRid(), - _externalState->getClientHostAndPort(opCtx)); -} - bool ReplicationCoordinatorImpl::buildsIndexes() { stdx::lock_guard<stdx::mutex> lk(_mutex); if (_selfIndex == -1) { @@ -2854,9 +2810,7 @@ bool ReplicationCoordinatorImpl::buildsIndexes() { std::vector<HostAndPort> ReplicationCoordinatorImpl::getHostsWrittenTo(const OpTime& op, bool durablyWritten) { stdx::lock_guard<stdx::mutex> lk(_mutex); - /* skip self in master-slave mode because our own HostAndPort is unknown */ - const bool skipSelf = getReplicationMode() == modeMasterSlave; - return _topCoord->getHostsWrittenTo(op, durablyWritten, skipSelf); + return _topCoord->getHostsWrittenTo(op, durablyWritten); } std::vector<HostAndPort> ReplicationCoordinatorImpl::getOtherNodesInReplSet() const { @@ -2890,15 +2844,6 @@ Status ReplicationCoordinatorImpl::_checkIfWriteConcernCanBeSatisfied_inlock( "No replication enabled when checking if write concern can be satisfied"); } - if (getReplicationMode() == modeMasterSlave) { - if (!writeConcern.wMode.empty()) { - return Status(ErrorCodes::UnknownReplWriteConcern, - "Cannot use named write concern modes in master-slave"); - } - // No way to know how many slaves there are, so assume any numeric mode is possible. - return Status::OK(); - } - invariant(getReplicationMode() == modeReplSet); return _rsConfig.checkIfWriteConcernCanBeSatisfied(writeConcern); } diff --git a/src/mongo/db/repl/replication_coordinator_impl.h b/src/mongo/db/repl/replication_coordinator_impl.h index 4dbf0dd321d..d62bf217071 100644 --- a/src/mongo/db/repl/replication_coordinator_impl.h +++ b/src/mongo/db/repl/replication_coordinator_impl.h @@ -72,7 +72,6 @@ namespace repl { class ElectCmdRunner; class FreshnessChecker; -class HandshakeArgs; class HeartbeatResponseAction; class LastVote; class OplogReader; @@ -146,8 +145,6 @@ public: virtual bool shouldRelaxIndexConstraints(OperationContext* opCtx, const NamespaceString& ns); - virtual Status setLastOptimeForSlave(const OID& rid, const Timestamp& ts); - virtual void setMyLastAppliedOpTime(const OpTime& opTime); virtual void setMyLastDurableOpTime(const OpTime& opTime); @@ -170,8 +167,6 @@ public: virtual OID getElectionId() override; - virtual OID getMyRID() const override; - virtual int getMyId() const override; virtual Status setFollowerMode(const MemberState& newState) override; @@ -236,9 +231,6 @@ public: virtual Status processReplSetUpdatePosition(const UpdatePositionArgs& updates, long long* configVersion) override; - virtual Status processHandshake(OperationContext* opCtx, - const HandshakeArgs& handshake) override; - virtual bool buildsIndexes() override; virtual std::vector<HostAndPort> getHostsWrittenTo(const OpTime& op, @@ -634,8 +626,6 @@ private: bool _canAcceptWritesFor_inlock(const NamespaceString& ns); - OID _getMyRID_inlock() const; - int _getMyId_inlock() const; OpTime _getMyLastAppliedOpTime_inlock() const; @@ -1165,10 +1155,6 @@ private: // Pointer to the ReplicationCoordinatorExternalState owned by this ReplicationCoordinator. std::unique_ptr<ReplicationCoordinatorExternalState> _externalState; // (PS) - // Our RID, used to identify us to our sync source when sending replication progress - // updates upstream. Set once in startReplication() and then never modified again. - OID _myRID; // (M) - // list of information about clients waiting on replication. Does *not* own the WaiterInfos. WaiterList _replicationWaiterList; // (M) @@ -1235,7 +1221,7 @@ private: // Flag that indicates whether writes to databases other than "local" are allowed. Used to // answer canAcceptWritesForDatabase() and canAcceptWritesFor() questions. - // Always true for standalone nodes and masters in master-slave relationships. + // Always true for standalone nodes. bool _canAcceptNonLocalWrites; // (GM) // Flag that indicates whether reads from databases other than "local" are allowed. Unlike diff --git a/src/mongo/db/repl/replication_coordinator_impl_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_test.cpp index c981c0af10f..bd9f1dd9ec3 100644 --- a/src/mongo/db/repl/replication_coordinator_impl_test.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl_test.cpp @@ -39,7 +39,6 @@ #include "mongo/bson/util/bson_extract.h" #include "mongo/db/operation_context_noop.h" #include "mongo/db/repl/bson_extract_optime.h" -#include "mongo/db/repl/handshake_args.h" #include "mongo/db/repl/is_master_response.h" #include "mongo/db/repl/optime.h" #include "mongo/db/repl/read_concern_args.h" @@ -1375,7 +1374,6 @@ protected: exitNetwork(); } - OID myRid; OID rid2; OID rid3; @@ -1396,7 +1394,6 @@ private: << "test3:1234"))), HostAndPort("test1", 1234)); ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY)); - myRid = getReplCoord()->getMyRID(); } }; @@ -1729,7 +1726,6 @@ private: << "test5:1234"))), HostAndPort("test1", 1234)); ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY)); - myRid = getReplCoord()->getMyRID(); } }; diff --git a/src/mongo/db/repl/replication_coordinator_mock.cpp b/src/mongo/db/repl/replication_coordinator_mock.cpp index bbc70047e36..5ff484259b4 100644 --- a/src/mongo/db/repl/replication_coordinator_mock.cpp +++ b/src/mongo/db/repl/replication_coordinator_mock.cpp @@ -175,10 +175,6 @@ bool ReplicationCoordinatorMock::shouldRelaxIndexConstraints(OperationContext* o return !canAcceptWritesFor(opCtx, ns); } -Status ReplicationCoordinatorMock::setLastOptimeForSlave(const OID& rid, const Timestamp& ts) { - return Status::OK(); -} - void ReplicationCoordinatorMock::setMyHeartbeatMessage(const std::string& msg) { // TODO } @@ -358,11 +354,6 @@ Status ReplicationCoordinatorMock::processReplSetUpdatePosition(const UpdatePosi return Status::OK(); } -Status ReplicationCoordinatorMock::processHandshake(OperationContext* opCtx, - const HandshakeArgs& handshake) { - return Status::OK(); -} - bool ReplicationCoordinatorMock::buildsIndexes() { // TODO return true; diff --git a/src/mongo/db/repl/replication_coordinator_mock.h b/src/mongo/db/repl/replication_coordinator_mock.h index afcb5daf6df..1151f731893 100644 --- a/src/mongo/db/repl/replication_coordinator_mock.h +++ b/src/mongo/db/repl/replication_coordinator_mock.h @@ -111,8 +111,6 @@ public: virtual bool shouldRelaxIndexConstraints(OperationContext* opCtx, const NamespaceString& ns); - virtual Status setLastOptimeForSlave(const OID& rid, const Timestamp& ts); - virtual void setMyLastAppliedOpTime(const OpTime& opTime); virtual void setMyLastDurableOpTime(const OpTime& opTime); @@ -198,8 +196,6 @@ public: virtual Status processReplSetUpdatePosition(const UpdatePositionArgs& updates, long long* configVersion); - virtual Status processHandshake(OperationContext* opCtx, const HandshakeArgs& handshake); - virtual bool buildsIndexes(); virtual std::vector<HostAndPort> getHostsWrittenTo(const OpTime& op, bool durablyWritten); diff --git a/src/mongo/db/repl/replication_info.cpp b/src/mongo/db/repl/replication_info.cpp index 7ee9664690e..bed3b9aeca2 100644 --- a/src/mongo/db/repl/replication_info.cpp +++ b/src/mongo/db/repl/replication_info.cpp @@ -198,14 +198,10 @@ public: // TODO(siyuan) Output term of OpTime result.append("latestOptime", replCoord->getMyLastAppliedOpTime().getTimestamp()); - const std::string& oplogNS = - replCoord->getReplicationMode() == ReplicationCoordinator::modeReplSet - ? NamespaceString::kRsOplogNamespace.ns() - : masterSlaveOplogName; BSONObj o; uassert(17347, "Problem reading earliest entry from oplog", - Helpers::getSingleton(opCtx, oplogNS.c_str(), o)); + Helpers::getSingleton(opCtx, NamespaceString::kRsOplogNamespace.ns().c_str(), o)); result.append("earliestOptime", o["ts"].timestamp()); return result.obj(); } @@ -220,8 +216,7 @@ public: return AllowedOnSecondary::kAlways; } std::string help() const override { - return "Check if this server is primary for a replica pair/set; also if it is --master or " - "--slave in simple master/slave setups.\n" + return "Check if this server is primary for a replica set\n" "{ isMaster : 1 }"; } virtual bool supportsWriteConcern(const BSONObj& cmd) const override { diff --git a/src/mongo/db/repl/topology_coordinator.cpp b/src/mongo/db/repl/topology_coordinator.cpp index a8eba4a89d2..b5f763f56d2 100644 --- a/src/mongo/db/repl/topology_coordinator.cpp +++ b/src/mongo/db/repl/topology_coordinator.cpp @@ -40,7 +40,6 @@ #include "mongo/db/client.h" #include "mongo/db/mongod_options.h" #include "mongo/db/operation_context.h" -#include "mongo/db/repl/handshake_args.h" #include "mongo/db/repl/heartbeat_response_action.h" #include "mongo/db/repl/is_master_response.h" #include "mongo/db/repl/isself.h" @@ -1194,14 +1193,9 @@ HeartbeatResponseAction TopologyCoordinator::checkMemberTimeouts(Date_t now) { } std::vector<HostAndPort> TopologyCoordinator::getHostsWrittenTo(const OpTime& op, - bool durablyWritten, - bool skipSelf) { + bool durablyWritten) { std::vector<HostAndPort> hosts; for (const auto& memberData : _memberData) { - if (skipSelf && memberData.isSelf()) { - continue; - } - if (durablyWritten) { if (memberData.getLastDurableOpTime() < op) { continue; @@ -1350,28 +1344,6 @@ StatusWith<bool> TopologyCoordinator::setLastOptime(const UpdatePositionArgs::Up return advancedOpTime; } -void TopologyCoordinator::setLastOptimeForSlave(const OID& rid, const OpTime& opTime, Date_t now) { - massert(28576, - "Received an old style replication progress update, which is only used for Master/" - "Slave replication now, but this node is not using Master/Slave replication. " - "This is likely caused by an old (pre-2.6) member syncing from this node.", - !_rsConfig.isInitialized()); - auto* memberData = _findMemberDataByRid(rid); - if (memberData) { - memberData->advanceLastAppliedOpTime(opTime, now); - } else { - invariant(!_memberData.empty()); // Must always have our own entry first. - _memberData.emplace_back(); - memberData = &_memberData.back(); - memberData->setRid(rid); - memberData->setLastAppliedOpTime(opTime, now); - } -} - -void TopologyCoordinator::setMyRid(const OID& rid) { - _selfMemberData().setRid(rid); -} - MemberData* TopologyCoordinator::_findMemberDataByMemberId(const int memberId) { const int memberIndex = _getMemberIndex(memberId); if (memberIndex >= 0) @@ -1379,30 +1351,6 @@ MemberData* TopologyCoordinator::_findMemberDataByMemberId(const int memberId) { return nullptr; } -MemberData* TopologyCoordinator::_findMemberDataByRid(const OID rid) { - for (auto& memberData : _memberData) { - if (memberData.getRid() == rid) - return &memberData; - } - return nullptr; -} - -Status TopologyCoordinator::processHandshake(const OID& rid, const HostAndPort& hostAndPort) { - if (_rsConfig.isInitialized()) { - return Status(ErrorCodes::IllegalOperation, - "The handshake command is only used for master/slave replication"); - } - auto* memberData = _findMemberDataByRid(rid); - if (!memberData) { - invariant(!_memberData.empty()); // Must always have our own entry first. - _memberData.emplace_back(); - auto& newMember = _memberData.back(); - newMember.setRid(rid); - newMember.setHostAndPort(hostAndPort); - } - return Status::OK(); -} - HeartbeatResponseAction TopologyCoordinator::_updatePrimaryFromHBDataV1( int updatedConfigIndex, const MemberState& originalState, Date_t now) { // @@ -2206,7 +2154,6 @@ void TopologyCoordinator::fillMemberData(BSONObjBuilder* result) { { for (const auto& memberData : _memberData) { BSONObjBuilder entry(replicationProgress.subobjStart()); - entry.append("rid", memberData.getRid()); const auto lastDurableOpTime = memberData.getLastDurableOpTime(); if (_rsConfig.getProtocolVersion() == 1) { BSONObjBuilder opTime(entry.subobjStart("optime")); @@ -2489,8 +2436,8 @@ const int TopologyCoordinator::_selfMemberDataIndex() const { invariant(!_memberData.empty()); if (_selfIndex >= 0) return _selfIndex; - // In master-slave mode, the first entry is for self. If there is no config - // or we're not in the config, the first-and-only entry should be for self. + // If there is no config or we're not in the config, the first-and-only entry should be for + // self. return 0; } diff --git a/src/mongo/db/repl/topology_coordinator.h b/src/mongo/db/repl/topology_coordinator.h index b23f0967922..306a2e896c3 100644 --- a/src/mongo/db/repl/topology_coordinator.h +++ b/src/mongo/db/repl/topology_coordinator.h @@ -472,9 +472,7 @@ public: * "durablyWritten" indicates whether the operation has to be durably applied. * "skipSelf" means to exclude this node whether or not the op has been applied. */ - std::vector<HostAndPort> getHostsWrittenTo(const OpTime& op, - bool durablyWritten, - bool skipSelf); + std::vector<HostAndPort> getHostsWrittenTo(const OpTime& op, bool durablyWritten); /** * Marks a member as down from our perspective and returns a bool which indicates if we can no @@ -543,26 +541,6 @@ public: StatusWith<bool> setLastOptime(const UpdatePositionArgs::UpdateInfo& args, Date_t now, long long* configVersion); - /* - * Sets the last optimes for a slave node. - * - * Used only in master/slave replication. - */ - - void setLastOptimeForSlave(const OID& rid, const OpTime& opTime, Date_t now); - - /* - * Set the RID for this node. - * - * Used only in master/slave replication. - */ - void setMyRid(const OID& rid); - - /** - * Process a handshake command, adding the slave to the member list if it isn't already there. - * Used only in master/slave mode - */ - Status processHandshake(const OID& rid, const HostAndPort& hostAndPort); /** * If getRole() == Role::candidate and this node has not voted too recently, updates the @@ -876,13 +854,6 @@ private: */ MemberData* _findMemberDataByMemberId(const int memberId); - /* - * Returns information we have on the state of the node identified by rid. Returns - * nullptr if rid is not found in the heartbeat data. This method is used only for - * master/slave replication. - */ - MemberData* _findMemberDataByRid(const OID rid); - // Returns NULL if there is no primary, or the MemberConfig* for the current primary const MemberConfig* _currentPrimaryMember() const; |