diff options
45 files changed, 49 insertions, 796 deletions
diff --git a/jstests/noPassthrough/internal_validate_features_as_master.js b/jstests/noPassthrough/internal_validate_features_as_master.js index 1ae2a7764e2..d60ee184b7c 100644 --- a/jstests/noPassthrough/internal_validate_features_as_master.js +++ b/jstests/noPassthrough/internal_validate_features_as_master.js @@ -13,7 +13,7 @@ assert.eq(res.internalValidateFeaturesAsMaster, true); MongoRunner.stopMongod(conn); - // internalValidateFeaturesAsMaster cannot be set with --replSet, --master, or --slave. + // internalValidateFeaturesAsMaster cannot be set with --replSet. conn = MongoRunner.runMongod( {replSet: "replSetName", setParameter: "internalValidateFeaturesAsMaster=0"}); assert.eq(null, conn, "mongod was unexpectedly able to start up"); @@ -22,18 +22,6 @@ {replSet: "replSetName", setParameter: "internalValidateFeaturesAsMaster=1"}); assert.eq(null, conn, "mongod was unexpectedly able to start up"); - conn = MongoRunner.runMongod({master: "", setParameter: "internalValidateFeaturesAsMaster=0"}); - assert.eq(null, conn, "mongod was unexpectedly able to start up"); - - conn = MongoRunner.runMongod({master: "", setParameter: "internalValidateFeaturesAsMaster=1"}); - assert.eq(null, conn, "mongod was unexpectedly able to start up"); - - conn = MongoRunner.runMongod({slave: "", setParameter: "internalValidateFeaturesAsMaster=0"}); - assert.eq(null, conn, "mongod was unexpectedly able to start up"); - - conn = MongoRunner.runMongod({slave: "", setParameter: "internalValidateFeaturesAsMaster=1"}); - assert.eq(null, conn, "mongod was unexpectedly able to start up"); - // internalValidateFeaturesAsMaster cannot be set via runtime parameter. conn = MongoRunner.runMongod({}); assert.commandFailed( diff --git a/src/mongo/client/embedded/replication_coordinator_embedded.cpp b/src/mongo/client/embedded/replication_coordinator_embedded.cpp index c257f050e33..affd8a085ba 100644 --- a/src/mongo/client/embedded/replication_coordinator_embedded.cpp +++ b/src/mongo/client/embedded/replication_coordinator_embedded.cpp @@ -178,10 +178,6 @@ void ReplicationCoordinatorEmbedded::signalUpstreamUpdater() { UASSERT_NOT_IMPLEMENTED; } -Status ReplicationCoordinatorEmbedded::setLastOptimeForSlave(const OID&, const Timestamp&) { - UASSERT_NOT_IMPLEMENTED; -} - void ReplicationCoordinatorEmbedded::setMyHeartbeatMessage(const std::string&) { UASSERT_NOT_IMPLEMENTED; } @@ -241,10 +237,6 @@ OID ReplicationCoordinatorEmbedded::getElectionId() { UASSERT_NOT_IMPLEMENTED; } -OID ReplicationCoordinatorEmbedded::getMyRID() const { - UASSERT_NOT_IMPLEMENTED; -} - int ReplicationCoordinatorEmbedded::getMyId() const { UASSERT_NOT_IMPLEMENTED; } @@ -336,10 +328,6 @@ Status ReplicationCoordinatorEmbedded::processReplSetUpdatePosition(const Update UASSERT_NOT_IMPLEMENTED; } -Status ReplicationCoordinatorEmbedded::processHandshake(OperationContext*, const HandshakeArgs&) { - UASSERT_NOT_IMPLEMENTED; -} - bool ReplicationCoordinatorEmbedded::buildsIndexes() { UASSERT_NOT_IMPLEMENTED; } diff --git a/src/mongo/client/embedded/replication_coordinator_embedded.h b/src/mongo/client/embedded/replication_coordinator_embedded.h index e131b8e9449..6e6e9368936 100644 --- a/src/mongo/client/embedded/replication_coordinator_embedded.h +++ b/src/mongo/client/embedded/replication_coordinator_embedded.h @@ -102,8 +102,6 @@ public: Status checkIfWriteConcernCanBeSatisfied(const WriteConcernOptions&) const override; - Status setLastOptimeForSlave(const OID&, const Timestamp&) override; - void setMyLastAppliedOpTime(const repl::OpTime&) override; void setMyLastDurableOpTime(const repl::OpTime&) override; @@ -125,8 +123,6 @@ public: OID getElectionId() override; - OID getMyRID() const override; - int getMyId() const override; Status setFollowerMode(const repl::MemberState&) override; @@ -180,8 +176,6 @@ public: Status processReplSetUpdatePosition(const repl::UpdatePositionArgs&, long long*) override; - Status processHandshake(OperationContext*, const repl::HandshakeArgs&) override; - bool buildsIndexes() override; std::vector<HostAndPort> getHostsWrittenTo(const repl::OpTime&, bool) override; diff --git a/src/mongo/db/catalog/database_impl.cpp b/src/mongo/db/catalog/database_impl.cpp index e6cc8ef537c..3e3b1871a2e 100644 --- a/src/mongo/db/catalog/database_impl.cpp +++ b/src/mongo/db/catalog/database_impl.cpp @@ -504,14 +504,10 @@ Status DatabaseImpl::dropCollectionEvenIfSystem(OperationContext* opCtx, // Drop unreplicated collections immediately. // If 'dropOpTime' is provided, we should proceed to rename the collection. - // Under master/slave, collections are always dropped immediately. This is because drop-pending - // collections support the rollback process which is not applicable to master/slave. auto replCoord = repl::ReplicationCoordinator::get(opCtx); auto opObserver = opCtx->getServiceContext()->getOpObserver(); auto isOplogDisabledForNamespace = replCoord->isOplogDisabledFor(opCtx, fullns); - auto isMasterSlave = - repl::ReplicationCoordinator::modeMasterSlave == replCoord->getReplicationMode(); - if ((dropOpTime.isNull() && isOplogDisabledForNamespace) || isMasterSlave) { + if (dropOpTime.isNull() && isOplogDisabledForNamespace) { auto status = _finishDropCollection(opCtx, fullns, collection); if (!status.isOK()) { return status; diff --git a/src/mongo/db/clientcursor.cpp b/src/mongo/db/clientcursor.cpp index 27d851fa043..f960afc60d7 100644 --- a/src/mongo/db/clientcursor.cpp +++ b/src/mongo/db/clientcursor.cpp @@ -129,23 +129,6 @@ void ClientCursor::dispose(OperationContext* opCtx) { _disposed = true; } -void ClientCursor::updateSlaveLocation(OperationContext* opCtx) { - if (_slaveReadTill.isNull()) - return; - - verify(_nss.isOplog()); - - Client* c = opCtx->getClient(); - verify(c); - OID rid = repl::ReplClientInfo::forClient(c).getRemoteID(); - if (!rid.isSet()) - return; - - repl::ReplicationCoordinator::get(opCtx) - ->setLastOptimeForSlave(rid, _slaveReadTill) - .transitional_ignore(); -} - // // Pin methods // diff --git a/src/mongo/db/clientcursor.h b/src/mongo/db/clientcursor.h index b811fc47722..42e7c20f069 100644 --- a/src/mongo/db/clientcursor.h +++ b/src/mongo/db/clientcursor.h @@ -212,23 +212,6 @@ public: _leftoverMaxTimeMicros = leftoverMaxTimeMicros; } - // - // Replication-related methods. - // - - // Used to report replication position only in master-slave, so we keep them as TimeStamp rather - // than OpTime. - void updateSlaveLocation(OperationContext* opCtx); - - void slaveReadTill(const Timestamp& t) { - _slaveReadTill = t; - } - - /** Just for testing. */ - Timestamp getSlaveReadTill() const { - return _slaveReadTill; - } - /** * Returns the server-wide the count of living cursors. Such a cursor is called an "open * cursor". @@ -325,9 +308,6 @@ private: // See the QueryOptions enum in dbclientinterface.h. const int _queryOptions = 0; - // The replication position only used in master-slave. - Timestamp _slaveReadTill; - // Unused maxTime budget for this cursor. Microseconds _leftoverMaxTimeMicros = Microseconds::max(); diff --git a/src/mongo/db/commands/feature_compatibility_version.h b/src/mongo/db/commands/feature_compatibility_version.h index feb7a8190f9..727ef8529fe 100644 --- a/src/mongo/db/commands/feature_compatibility_version.h +++ b/src/mongo/db/commands/feature_compatibility_version.h @@ -41,7 +41,7 @@ class OperationContext; /** * Startup parameter to ignore featureCompatibilityVersion checks. This parameter cannot be set if - * the node is started with --replSet, --master, or --slave. This should never be set by end users. + * the node is started with --replSet. This should never be set by end users. */ extern bool internalValidateFeaturesAsMaster; diff --git a/src/mongo/db/op_observer_impl.cpp b/src/mongo/db/op_observer_impl.cpp index c343ff63050..c8a470f5b91 100644 --- a/src/mongo/db/op_observer_impl.cpp +++ b/src/mongo/db/op_observer_impl.cpp @@ -93,14 +93,6 @@ repl::OpTime logOperation(OperationContext* opCtx, } /** - * Returns whether we're a master using master-slave replication. - */ -bool isMasterSlave(OperationContext* opCtx) { - return repl::ReplicationCoordinator::get(opCtx)->getReplicationMode() == - repl::ReplicationCoordinator::modeMasterSlave; -} - -/** * Updates the session state with the last write timestamp and transaction for that session. * * In the case of writes with transaction/statement id, this method will be recursively entered a @@ -316,7 +308,7 @@ void OpObserverImpl::onCreateIndex(OperationContext* opCtx, bool fromMigrate) { const NamespaceString systemIndexes{nss.getSystemIndexesCollection()}; - if (uuid && !isMasterSlave(opCtx)) { + if (uuid) { BSONObjBuilder builder; builder.append("createIndexes", nss.coll()); @@ -765,7 +757,7 @@ repl::OpTime OpObserverImpl::onRenameCollection(OperationContext* const opCtx, builder.append("renameCollection", fromCollection.ns()); builder.append("to", toCollection.ns()); builder.append("stayTemp", stayTemp); - if (dropTargetUUID && !isMasterSlave(opCtx)) { + if (dropTargetUUID) { dropTargetUUID->appendToBuilder(&builder, "dropTarget"); } else { builder.append("dropTarget", dropTarget); diff --git a/src/mongo/db/query/find.cpp b/src/mongo/db/query/find.cpp index fdd402b76bd..43d86c1beab 100644 --- a/src/mongo/db/query/find.cpp +++ b/src/mongo/db/query/find.cpp @@ -163,8 +163,7 @@ namespace { * * Returns the number of documents in the batch in 'numResults', which must be initialized to * zero by the caller. Returns the final ExecState returned by the cursor in *state. Returns - * whether or not to save the ClientCursor in 'shouldSaveCursor'. Returns the slave's time to - * read until in 'slaveReadTill' (for master/slave). + * whether or not to save the ClientCursor in 'shouldSaveCursor'. * * Returns an OK status if the batch was successfully generated, and a non-OK status if the * PlanExecutor encounters a failure. @@ -173,7 +172,6 @@ void generateBatch(int ntoreturn, ClientCursor* cursor, BufBuilder* bb, int* numResults, - Timestamp* slaveReadTill, PlanExecutor::ExecState* state) { PlanExecutor* exec = cursor->getExecutor(); @@ -191,14 +189,6 @@ void generateBatch(int ntoreturn, // Count the result. (*numResults)++; - - // Possibly note slave's position in the oplog. - if (cursor->queryOptions() & QueryOption_OplogReplay) { - BSONElement e = obj["ts"]; - if (BSONType::Date == e.type() || BSONType::bsonTimestamp == e.type()) { - *slaveReadTill = e.timestamp(); - } - } } // Propagate any errors to the caller. @@ -386,11 +376,6 @@ Message getMore(OperationContext* opCtx, } opCtx->checkForInterrupt(); // May trigger maxTimeAlwaysTimeOut fail point. - cc->updateSlaveLocation(opCtx); - - // If we're replaying the oplog, we save the last time that we read. - Timestamp slaveReadTill; - // What number result are we starting at? Used to fill out the reply. startingResult = cc->pos(); @@ -433,7 +418,7 @@ Message getMore(OperationContext* opCtx, PlanSummaryStats preExecutionStats; Explain::getSummaryStats(*exec, &preExecutionStats); - generateBatch(ntoreturn, cc, &bb, &numResults, &slaveReadTill, &state); + generateBatch(ntoreturn, cc, &bb, &numResults, &state); // If this is an await data cursor, and we hit EOF without generating any results, then // we block waiting for new data to arrive. @@ -458,7 +443,7 @@ Message getMore(OperationContext* opCtx, // We woke up because either the timed_wait expired, or there was more data. Either // way, attempt to generate another batch of results. - generateBatch(ntoreturn, cc, &bb, &numResults, &slaveReadTill, &state); + generateBatch(ntoreturn, cc, &bb, &numResults, &state); } PlanSummaryStats postExecutionStats; @@ -501,11 +486,6 @@ Message getMore(OperationContext* opCtx, LOG(5) << "getMore saving client cursor ended with state " << PlanExecutor::statestr(state); - // Possibly note slave's position in the oplog. - if ((cc->queryOptions() & QueryOption_OplogReplay) && !slaveReadTill.isNull()) { - cc->slaveReadTill(slaveReadTill); - } - *exhaust = cc->queryOptions() & QueryOption_Exhaust; // We assume that cursors created through a DBDirectClient are always used from their @@ -633,9 +613,6 @@ std::string runQuery(OperationContext* opCtx, // How many results have we obtained from the executor? int numResults = 0; - // If we're replaying the oplog, we save the last time that we read. - Timestamp slaveReadTill; - BSONObj obj; PlanExecutor::ExecState state; @@ -658,14 +635,6 @@ std::string runQuery(OperationContext* opCtx, // Count the result. ++numResults; - // Possibly note slave's position in the oplog. - if (qr.isOplogReplay()) { - BSONElement e = obj["ts"]; - if (Date == e.type() || bsonTimestamp == e.type()) { - slaveReadTill = e.timestamp(); - } - } - if (FindCommon::enoughForFirstBatch(qr, numResults)) { LOG(5) << "Enough for first batch, wantMore=" << qr.wantMore() << " ntoreturn=" << qr.getNToReturn().value_or(0) @@ -711,11 +680,6 @@ std::string runQuery(OperationContext* opCtx, << " results"; // TODO document - if (qr.isOplogReplay() && !slaveReadTill.isNull()) { - pinnedCursor.getCursor()->slaveReadTill(slaveReadTill); - } - - // TODO document if (qr.isExhaust()) { curOp.debug().exhaust = true; } diff --git a/src/mongo/db/read_concern.cpp b/src/mongo/db/read_concern.cpp index 132680d37d1..b5af878c5b8 100644 --- a/src/mongo/db/read_concern.cpp +++ b/src/mongo/db/read_concern.cpp @@ -212,7 +212,7 @@ Status waitForReadConcern(OperationContext* opCtx, if (readConcernArgs.getLevel() == repl::ReadConcernLevel::kLinearizableReadConcern) { if (replCoord->getReplicationMode() != repl::ReplicationCoordinator::modeReplSet) { - // For master/slave and standalone nodes, Linearizable Read is not supported. + // For standalone nodes, Linearizable Read is not supported. return {ErrorCodes::NotAReplicaSet, "node needs to be a replica set member to use read concern"}; } 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; diff --git a/src/mongo/db/s/chunk_move_write_concern_options.cpp b/src/mongo/db/s/chunk_move_write_concern_options.cpp index 7cccc644789..f9d6095229f 100644 --- a/src/mongo/db/s/chunk_move_write_concern_options.cpp +++ b/src/mongo/db/s/chunk_move_write_concern_options.cpp @@ -87,14 +87,6 @@ StatusWith<WriteConcernOptions> ChunkMoveWriteConcernOptions::getEffectiveWriteC repl::ReplicationCoordinator* replCoordinator = repl::ReplicationCoordinator::get(opCtx); - if (replCoordinator->getReplicationMode() == - repl::ReplicationCoordinator::modeMasterSlave && - writeConcern.shouldWaitForOtherNodes()) { - warning() << "moveChunk cannot check if secondary throttle setting " - << writeConcern.toBSON() - << " can be enforced in a master slave configuration"; - } - Status status = replCoordinator->checkIfWriteConcernCanBeSatisfied(writeConcern); if (!status.isOK() && status != ErrorCodes::NoReplicationEnabled) { return status; diff --git a/src/mongo/db/server_options.h b/src/mongo/db/server_options.h index 5e4e934e2b0..7765a3579a0 100644 --- a/src/mongo/db/server_options.h +++ b/src/mongo/db/server_options.h @@ -236,11 +236,10 @@ struct ServerGlobalParams { } featureCompatibility; - // Feature validation differs depending on the role of a mongod in a replica set or - // master/slave configuration. Masters/primaries can accept user-initiated writes and - // validate based on the feature compatibility version. A secondary/slave (which is not also - // a master) always validates in the upgraded mode so that it can sync new features, even - // when in the downgraded feature compatibility mode. + // Feature validation differs depending on the role of a mongod in a replica set. Replica set + // primaries can accept user-initiated writes and validate based on the feature compatibility + // version. A secondary always validates in the upgraded mode so that it can sync new features, + // even when in the downgraded feature compatibility mode. AtomicWord<bool> validateFeaturesAsMaster{true}; std::vector<std::string> disabledSecureAllocatorDomains; diff --git a/src/mongo/db/server_options_helpers.cpp b/src/mongo/db/server_options_helpers.cpp index c3b525ba8a1..c521a8921ab 100644 --- a/src/mongo/db/server_options_helpers.cpp +++ b/src/mongo/db/server_options_helpers.cpp @@ -603,13 +603,11 @@ Status validateServerOptions(const moe::Environment& params) { if (parameters.find("internalValidateFeaturesAsMaster") != parameters.end()) { // Command line options that are disallowed when internalValidateFeaturesAsMaster is // specified. - for (const auto& disallowedOption : {"replication.replSet", "master", "slave"}) { - if (params.count(disallowedOption)) { - return Status(ErrorCodes::BadValue, - str::stream() - << "Cannot specify both internalValidateFeaturesAsMaster and " - << disallowedOption); - } + if (params.count("replication.replSet")) { + return Status(ErrorCodes::BadValue, + str::stream() << // + "Cannot specify both internalValidateFeaturesAsMaster and " + "replication.replSet"); } } } diff --git a/src/mongo/db/startup_warnings_mongod.cpp b/src/mongo/db/startup_warnings_mongod.cpp index 602810a373b..2f0ad080ee0 100644 --- a/src/mongo/db/startup_warnings_mongod.cpp +++ b/src/mongo/db/startup_warnings_mongod.cpp @@ -396,18 +396,6 @@ void logMongodStartupWarnings(const StorageGlobalParams& storageParams, warned = true; } - // Check if in master-slave mode - auto replCoord = repl::ReplicationCoordinator::get(svcCtx); - if (replCoord->getReplicationMode() == repl::ReplicationCoordinator::modeMasterSlave) { - log() << startupWarningsLog; - log() << "** WARNING: This node was started in master-slave replication mode." - << startupWarningsLog; - log() << "** Master-slave replication is deprecated and subject to be removed " - << startupWarningsLog; - log() << "** in a future version." << startupWarningsLog; - warned = true; - } - if (warned) { log() << startupWarningsLog; } diff --git a/src/mongo/db/storage/wiredtiger/SConscript b/src/mongo/db/storage/wiredtiger/SConscript index 7378649b128..a957b7103f1 100644 --- a/src/mongo/db/storage/wiredtiger/SConscript +++ b/src/mongo/db/storage/wiredtiger/SConscript @@ -75,8 +75,6 @@ if wiredtiger: 'storage_wiredtiger_customization_hooks', ], LIBDEPS_PRIVATE= [ - # SERVER-31802 : remove this. - '$BUILD_DIR/mongo/db/repl/repl_coordinator_interface', '$BUILD_DIR/mongo/util/options_parser/options_parser', ], ) diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h index 0d25901d6fc..9ad010a0957 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h @@ -241,7 +241,7 @@ public: /** * Initializes a background job to remove excess documents in the oplog collections. * This applies to the capped collections in the local.oplog.* namespaces (specifically - * local.oplog.rs for replica sets and local.oplog.$main for master/slave replication). + * local.oplog.rs for replica sets). * Returns true if a background job is running for the namespace. */ static bool initRsOplogBackgroundThread(StringData ns); diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.cpp index a7d086677d2..cd541d262f0 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.cpp @@ -73,21 +73,13 @@ void WiredTigerOplogManager::start(OperationContext* opCtx, setOplogReadTimestamp(Timestamp(kMinimumTimestamp)); } - auto replCoord = repl::ReplicationCoordinator::get(getGlobalServiceContext()); - bool isMasterSlave = false; - if (replCoord) { - isMasterSlave = - replCoord->getReplicationMode() == repl::ReplicationCoordinator::modeMasterSlave; - } - // Need to obtain the mutex before starting the thread, as otherwise it may race ahead // see _shuttingDown as true and quit prematurely. stdx::lock_guard<stdx::mutex> lk(_oplogVisibilityStateMutex); _oplogJournalThread = stdx::thread(&WiredTigerOplogManager::_oplogJournalThreadLoop, this, WiredTigerRecoveryUnit::get(opCtx)->getSessionCache(), - oplogRecordStore, - isMasterSlave); + oplogRecordStore); _isRunning = true; _shuttingDown = false; @@ -162,9 +154,8 @@ void WiredTigerOplogManager::triggerJournalFlush() { } } -void WiredTigerOplogManager::_oplogJournalThreadLoop(WiredTigerSessionCache* sessionCache, - WiredTigerRecordStore* oplogRecordStore, - bool isMasterSlave) noexcept { +void WiredTigerOplogManager::_oplogJournalThreadLoop( + WiredTigerSessionCache* sessionCache, WiredTigerRecordStore* oplogRecordStore) noexcept { Client::initThread("WTOplogJournalThread"); // This thread updates the oplog read timestamp, the timestamp used to read from the oplog with @@ -237,12 +228,6 @@ void WiredTigerOplogManager::_oplogJournalThreadLoop(WiredTigerSessionCache* ses // Wake up any await_data cursors and tell them more data might be visible now. oplogRecordStore->notifyCappedWaitersIfNeeded(); - - // For master/slave masters, set oldest timestamp here so that we clean up old timestamp - // data. SERVER-31802 - if (isMasterSlave) { - sessionCache->getKVEngine()->setStableTimestamp(Timestamp(newTimestamp)); - } } } diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h b/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h index ac744f0d502..ac3bdc03c2c 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h @@ -30,7 +30,6 @@ #pragma once #include "mongo/base/disallow_copying.h" -#include "mongo/db/repl/replication_coordinator.h" #include "mongo/db/storage/wiredtiger/wiredtiger_record_store.h" #include "mongo/stdx/condition_variable.h" #include "mongo/stdx/mutex.h" @@ -81,8 +80,7 @@ public: private: void _oplogJournalThreadLoop(WiredTigerSessionCache* sessionCache, - WiredTigerRecordStore* oplogRecordStore, - bool isMasterSlave) noexcept; + WiredTigerRecordStore* oplogRecordStore) noexcept; void _setOplogReadTimestamp(WithLock, uint64_t newTimestamp); diff --git a/src/mongo/dbtests/querytests.cpp b/src/mongo/dbtests/querytests.cpp index 05fed16d3de..644b4a7bb2a 100644 --- a/src/mongo/dbtests/querytests.cpp +++ b/src/mongo/dbtests/querytests.cpp @@ -635,65 +635,6 @@ public: } }; -class OplogReplaySlaveReadTill : public ClientBase { -public: - ~OplogReplaySlaveReadTill() { - _client.dropCollection("unittests.querytests.OplogReplaySlaveReadTill"); - } - void run() { - const char* ns = "unittests.querytests.OplogReplaySlaveReadTill"; - - // Create a capped collection of size 10. - _client.dropCollection(ns); - _client.createCollection(ns, 10, true); - - // The destructor for DBClientCursor runs killCursors. This must not be done while holding - // locks. - unique_ptr<DBClientCursor> c; - - { - Lock::DBLock lk(&_opCtx, "unittests", MODE_X); - OldClientContext ctx(&_opCtx, ns); - - BSONObj info; - _client.runCommand("unittests", - BSON("create" - << "querytests.OplogReplaySlaveReadTill" - << "capped" - << true - << "size" - << 8192), - info); - - Date_t one = Date_t::fromMillisSinceEpoch( - LogicalClock::get(&_opCtx)->reserveTicks(1).asTimestamp().asLL()); - Date_t two = Date_t::fromMillisSinceEpoch( - LogicalClock::get(&_opCtx)->reserveTicks(1).asTimestamp().asLL()); - Date_t three = Date_t::fromMillisSinceEpoch( - LogicalClock::get(&_opCtx)->reserveTicks(1).asTimestamp().asLL()); - insert(ns, BSON("ts" << Timestamp(one))); - insert(ns, BSON("ts" << Timestamp(two))); - insert(ns, BSON("ts" << Timestamp(three))); - c = _client.query(ns, - QUERY("ts" << GTE << Timestamp(two)).hint(BSON("$natural" << 1)), - 0, - 0, - 0, - QueryOption_OplogReplay | QueryOption_CursorTailable | - DBClientCursor::QueryOptionLocal_forceOpQuery); - ASSERT(c->more()); - ASSERT_EQUALS(Timestamp(two), c->next()["ts"].timestamp()); - long long cursorId = c->getCursorId(); - - auto pinnedCursor = unittest::assertGet(ctx.db() - ->getCollection(&_opCtx, ns) - ->getCursorManager() - ->pinCursor(&_opCtx, cursorId)); - ASSERT_EQUALS(three.toULL(), pinnedCursor.getCursor()->getSlaveReadTill().asULL()); - } - } -}; - class OplogReplayExplain : public ClientBase { public: ~OplogReplayExplain() { @@ -1737,7 +1678,6 @@ public: add<TailCappedOnly>(); add<TailableQueryOnId>(); add<OplogReplayMode>(); - add<OplogReplaySlaveReadTill>(); add<OplogReplayExplain>(); add<ArrayId>(); add<UnderscoreNs>(); diff --git a/src/mongo/shell/db.js b/src/mongo/shell/db.js index 4493b2a1192..300e446de95 100644 --- a/src/mongo/shell/db.js +++ b/src/mongo/shell/db.js @@ -1046,11 +1046,6 @@ var DB; use local db.getReplicationInfo(); </pre> - It is assumed that this database is a replication master -- the information returned is - about the operation log stored at local.oplog.$main on the replication master. (It also - works on a machine in a replica pair: for replica pairs, both machines are "masters" from - an internal database perspective. - <p> * @return Object timeSpan: time span of the oplog from start to end if slave is more out * of date than that, it can't recover without a complete resync */ @@ -1062,10 +1057,8 @@ var DB; var localCollections = localdb.getCollectionNames(); if (localCollections.indexOf('oplog.rs') >= 0) { oplog = 'oplog.rs'; - } else if (localCollections.indexOf('oplog.$main') >= 0) { - oplog = 'oplog.$main'; } else { - result.errmsg = "neither master/slave nor replica set replication detected"; + result.errmsg = "replication not detected"; return result; } @@ -1209,12 +1202,6 @@ var DB; for (i in status.members) { r(status.members[i]); } - } else if (L.sources.count() != 0) { - startOptimeDate = new Date(); - L.sources.find().forEach(g); - } else { - print("local.sources is empty; is this db a --slave?"); - return; } }; |