summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@mongodb.com>2015-03-26 18:45:22 -0400
committerAndy Schwerin <schwerin@mongodb.com>2015-04-06 10:16:23 -0400
commit90b7f774b818a1038cc525a9fca14207d8d5ff71 (patch)
tree604285e3d69ef379626ddd8f0a57068c287ea2ef
parent387e39a07522aec114a64146871eab2e015d7444 (diff)
downloadmongo-90b7f774b818a1038cc525a9fca14207d8d5ff71.tar.gz
SERVER-17817 Move replication-specific data from Client into ReplClientInfo decoration.
-rw-r--r--src/mongo/SConscript2
-rw-r--r--src/mongo/db/client.cpp11
-rw-r--r--src/mongo/db/client.h15
-rw-r--r--src/mongo/db/client_basic.h5
-rw-r--r--src/mongo/db/clientcursor.cpp3
-rw-r--r--src/mongo/db/commands/find_and_modify.cpp8
-rw-r--r--src/mongo/db/commands/get_last_error.cpp13
-rw-r--r--src/mongo/db/commands/write_commands/batch_executor.cpp9
-rw-r--r--src/mongo/db/dbcommands.cpp6
-rw-r--r--src/mongo/db/dbhelpers.cpp8
-rw-r--r--src/mongo/db/query/query_yield.cpp2
-rw-r--r--src/mongo/db/repl/SConscript3
-rw-r--r--src/mongo/db/repl/master_slave.cpp3
-rw-r--r--src/mongo/db/repl/oplog.cpp6
-rw-r--r--src/mongo/db/repl/repl_client_info.cpp45
-rw-r--r--src/mongo/db/repl/repl_client_info.h59
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.cpp7
-rw-r--r--src/mongo/db/repl/rs_initialsync.cpp3
-rw-r--r--src/mongo/db/repl/sync_tail.cpp3
-rw-r--r--src/mongo/dbtests/query_stage_ixscan.cpp2
-rw-r--r--src/mongo/s/d_migrate.cpp11
-rw-r--r--src/mongo/s/s_only.cpp1
22 files changed, 173 insertions, 52 deletions
diff --git a/src/mongo/SConscript b/src/mongo/SConscript
index 6601b088db4..3d61fd06a17 100644
--- a/src/mongo/SConscript
+++ b/src/mongo/SConscript
@@ -703,6 +703,7 @@ env.Library(
'db/service_context_noop.cpp',
],
LIBDEPS=[
+ 'util/decorable',
])
# Memory-mapped files support. Used by mongod and some tools.
@@ -1138,6 +1139,7 @@ env.Library(
],
LIBDEPS=[
'mongocommon',
+ 'util/decorable',
],
)
diff --git a/src/mongo/db/client.cpp b/src/mongo/db/client.cpp
index 610a46cbeb4..ea7ad692dc0 100644
--- a/src/mongo/db/client.cpp
+++ b/src/mongo/db/client.cpp
@@ -55,7 +55,6 @@
#include "mongo/db/instance.h"
#include "mongo/db/json.h"
#include "mongo/db/lasterror.h"
-#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/storage_options.h"
#include "mongo/s/chunk_version.h"
#include "mongo/s/d_state.h"
@@ -87,7 +86,6 @@ namespace {
} // namespace
-
boost::mutex Client::clientsMutex;
ClientSet Client::clients;
@@ -131,7 +129,6 @@ namespace {
_connectionId(p ? p->connectionId() : 0),
_inDirectClient(false),
_txn(NULL),
- _lastOp(0),
_shutdown(false) {
_curOp = new CurOp( this );
@@ -175,14 +172,6 @@ namespace {
return _locker.get();
}
- void Client::appendLastOp( BSONObjBuilder& b ) const {
- // _lastOp is never set if replication is off
- if (repl::getGlobalReplicationCoordinator()->getReplicationMode() ==
- repl::ReplicationCoordinator::modeReplSet || !_lastOp.isNull()) {
- b.appendTimestamp( "lastOp" , _lastOp.asDate() );
- }
- }
-
void Client::reportState(BSONObjBuilder& builder) {
builder.append("desc", desc());
diff --git a/src/mongo/db/client.h b/src/mongo/db/client.h
index bd3f83667a5..90cc2ff669f 100644
--- a/src/mongo/db/client.h
+++ b/src/mongo/db/client.h
@@ -39,7 +39,6 @@
#include <boost/scoped_ptr.hpp>
#include <boost/thread/thread.hpp>
-#include "mongo/bson/optime.h"
#include "mongo/db/client_basic.h"
#include "mongo/db/concurrency/d_concurrency.h"
#include "mongo/db/lasterror.h"
@@ -103,14 +102,10 @@ namespace mongo {
std::string clientAddress(bool includePort = false) const;
CurOp* curop() const { return _curOp; }
const std::string& desc() const { return _desc; }
- void setLastOp(OpTime op) { _lastOp = op; }
- OpTime getLastOp() const { return _lastOp; }
// Return a reference to the Locker for this client. Client retains ownership.
Locker* getLocker();
- /* report what the last operation was. used by getlasterror */
- void appendLastOp(BSONObjBuilder& b) const;
void reportState(BSONObjBuilder& builder);
// Ensures stability of the client's OperationContext. When the client is locked,
@@ -128,10 +123,6 @@ namespace mongo {
bool isInDirectClient() const { return _inDirectClient; }
void setInDirectClient(bool newVal) { _inDirectClient = newVal; }
- // Only used for master/slave
- void setRemoteID(const OID& rid) { _remoteId = rid; }
- OID getRemoteID() const { return _remoteId; }
-
ConnectionId getConnectionId() const { return _connectionId; }
bool isFromUserConnection() const { return _connectionId > 0; }
@@ -166,12 +157,6 @@ namespace mongo {
// allocating OS resources can be amortized over multiple operations.
boost::scoped_ptr<Locker> _locker;
- // Used by replication
- OpTime _lastOp;
-
- // Only used by master-slave
- OID _remoteId;
-
// Tracks if Client::shutdown() gets called (TODO: Is this necessary?)
bool _shutdown;
};
diff --git a/src/mongo/db/client_basic.h b/src/mongo/db/client_basic.h
index 9dd07127e72..04a7a38f0f3 100644
--- a/src/mongo/db/client_basic.h
+++ b/src/mongo/db/client_basic.h
@@ -31,6 +31,8 @@
#include <boost/noncopyable.hpp>
#include <boost/scoped_ptr.hpp>
+#include "mongo/base/disallow_copying.h"
+#include "mongo/util/decorable.h"
#include "mongo/util/net/hostandport.h"
#include "mongo/util/net/message_port.h"
@@ -47,7 +49,8 @@ namespace mongo {
* They should converge slowly
* The idea is this has the basic api so that not all code has to be duplicated
*/
- class ClientBasic : boost::noncopyable {
+ class ClientBasic : public Decorable<ClientBasic> {
+ MONGO_DISALLOW_COPYING(ClientBasic);
public:
virtual ~ClientBasic();
AuthenticationSession* getAuthenticationSession();
diff --git a/src/mongo/db/clientcursor.cpp b/src/mongo/db/clientcursor.cpp
index abbdfed817a..26bea429d2a 100644
--- a/src/mongo/db/clientcursor.cpp
+++ b/src/mongo/db/clientcursor.cpp
@@ -47,6 +47,7 @@
#include "mongo/db/curop.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/operation_context_impl.h"
+#include "mongo/db/repl/repl_client_info.h"
#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/server_parameters.h"
#include "mongo/util/exit.h"
@@ -189,7 +190,7 @@ namespace mongo {
Client* c = curop.getClient();
verify(c);
- OID rid = c->getRemoteID();
+ OID rid = repl::ReplClientInfo::forClient(c).getRemoteID();
if (!rid.isSet())
return;
diff --git a/src/mongo/db/commands/find_and_modify.cpp b/src/mongo/db/commands/find_and_modify.cpp
index 88fe9647e6c..34c00a80183 100644
--- a/src/mongo/db/commands/find_and_modify.cpp
+++ b/src/mongo/db/commands/find_and_modify.cpp
@@ -47,6 +47,7 @@
#include "mongo/db/ops/update_lifecycle_impl.h"
#include "mongo/db/projection.h"
#include "mongo/db/query/get_executor.h"
+#include "mongo/db/repl/repl_client_info.h"
#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/write_concern.h"
#include "mongo/util/log.h"
@@ -185,8 +186,11 @@ namespace mongo {
}
WriteConcernResult res;
- Status waitStatus = waitForWriteConcern(txn, txn->getClient()->getLastOp(), &res);
- appendCommandWCStatus(result, waitStatus);
+ wcResult = waitForWriteConcern(
+ txn,
+ repl::ReplClientInfo::forClient(txn->getClient()).getLastOp(),
+ &res);
+ appendCommandWCStatus(result, wcResult.getStatus());
return ok;
}
diff --git a/src/mongo/db/commands/get_last_error.cpp b/src/mongo/db/commands/get_last_error.cpp
index ea67056e881..2a376a369a4 100644
--- a/src/mongo/db/commands/get_last_error.cpp
+++ b/src/mongo/db/commands/get_last_error.cpp
@@ -33,10 +33,11 @@
#include "mongo/platform/basic.h"
#include "mongo/db/client.h"
-#include "mongo/db/curop.h"
#include "mongo/db/commands.h"
+#include "mongo/db/curop.h"
#include "mongo/db/field_parser.h"
#include "mongo/db/lasterror.h"
+#include "mongo/db/repl/repl_client_info.h"
#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/write_concern.h"
#include "mongo/util/log.h"
@@ -127,7 +128,13 @@ namespace mongo {
// Always append lastOp and connectionId
Client& c = *txn->getClient();
- c.appendLastOp( result );
+ if (repl::getGlobalReplicationCoordinator()->getReplicationMode() ==
+ repl::ReplicationCoordinator::modeReplSet) {
+ const OpTime lastOp = repl::ReplClientInfo::forClient(c).getLastOp();
+ if (!lastOp.isNull()) {
+ result.append("lastOp", lastOp);
+ }
+ }
// for sharding; also useful in general for debugging
result.appendNumber( "connectionId" , c.getConnectionId() );
@@ -144,7 +151,7 @@ namespace mongo {
bool lastOpTimePresent = extracted != FieldParser::FIELD_NONE;
if (!lastOpTimePresent) {
// Use the client opTime if no wOpTime is specified
- lastOpTime = c.getLastOp();
+ lastOpTime = repl::ReplClientInfo::forClient(c).getLastOp();
}
OID electionId;
diff --git a/src/mongo/db/commands/write_commands/batch_executor.cpp b/src/mongo/db/commands/write_commands/batch_executor.cpp
index 594a121c76c..cd03c645c32 100644
--- a/src/mongo/db/commands/write_commands/batch_executor.cpp
+++ b/src/mongo/db/commands/write_commands/batch_executor.cpp
@@ -61,6 +61,7 @@
#include "mongo/db/query/plan_executor.h"
#include "mongo/db/query/query_knobs.h"
#include "mongo/db/repl/oplog.h"
+#include "mongo/db/repl/repl_client_info.h"
#include "mongo/db/repl/repl_settings.h"
#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/server_parameters.h"
@@ -251,7 +252,10 @@ namespace mongo {
_txn->getCurOp()->setMessage( "waiting for write concern" );
WriteConcernResult res;
- Status status = waitForWriteConcern( _txn, _txn->getClient()->getLastOp(), &res );
+ Status status = waitForWriteConcern(
+ _txn,
+ repl::ReplClientInfo::forClient(_txn->getClient()).getLastOp(),
+ &res);
if ( !status.isOK() ) {
wcError.reset( toWriteConcernError( status, res ) );
@@ -350,7 +354,8 @@ namespace mongo {
repl::ReplicationCoordinator* replCoord = repl::getGlobalReplicationCoordinator();
const repl::ReplicationCoordinator::Mode replMode = replCoord->getReplicationMode();
if (replMode != repl::ReplicationCoordinator::modeNone) {
- response->setLastOp( _txn->getClient()->getLastOp() );
+ response->setLastOp(
+ repl::ReplClientInfo::forClient(_txn->getClient()).getLastOp());
if (replMode == repl::ReplicationCoordinator::modeReplSet) {
response->setElectionId(replCoord->getElectionId());
}
diff --git a/src/mongo/db/dbcommands.cpp b/src/mongo/db/dbcommands.cpp
index f0da12eeec7..6fa03e9909a 100644
--- a/src/mongo/db/dbcommands.cpp
+++ b/src/mongo/db/dbcommands.cpp
@@ -74,6 +74,7 @@
#include "mongo/db/query/internal_plans.h"
#include "mongo/db/query/query_planner.h"
#include "mongo/db/repair_database.h"
+#include "mongo/db/repl/repl_client_info.h"
#include "mongo/db/repl/repl_settings.h"
#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/storage/mmap_v1/dur_stats.h"
@@ -1554,7 +1555,10 @@ namespace mongo {
// For commands from mongos, append some info to help getLastError(w) work.
if (replCoord->getReplicationMode() == repl::ReplicationCoordinator::modeReplSet &&
shardingState.enabled()) {
- appendGLEHelperData(result, txn->getClient()->getLastOp(), replCoord->getElectionId());
+ appendGLEHelperData(
+ result,
+ repl::ReplClientInfo::forClient(txn->getClient()).getLastOp(),
+ replCoord->getElectionId());
}
return;
}
diff --git a/src/mongo/db/dbhelpers.cpp b/src/mongo/db/dbhelpers.cpp
index 6833aa33dc9..d74d74f493c 100644
--- a/src/mongo/db/dbhelpers.cpp
+++ b/src/mongo/db/dbhelpers.cpp
@@ -58,6 +58,7 @@
#include "mongo/db/query/internal_plans.h"
#include "mongo/db/query/query_planner.h"
#include "mongo/db/range_arithmetic.h"
+#include "mongo/db/repl/repl_client_info.h"
#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/storage_options.h"
#include "mongo/db/write_concern.h"
@@ -459,9 +460,10 @@ namespace mongo {
if (writeConcern.shouldWaitForOtherNodes() && numDeleted > 0) {
repl::ReplicationCoordinator::StatusAndDuration replStatus =
- repl::getGlobalReplicationCoordinator()->awaitReplication(txn,
- txn->getClient()->getLastOp(),
- writeConcern);
+ repl::getGlobalReplicationCoordinator()->awaitReplication(
+ txn,
+ repl::ReplClientInfo::forClient(txn->getClient()).getLastOp(),
+ writeConcern);
if (replStatus.status.code() == ErrorCodes::ExceededTimeLimit) {
warning(LogComponent::kSharding)
<< "replication to secondaries for removeRange at "
diff --git a/src/mongo/db/query/query_yield.cpp b/src/mongo/db/query/query_yield.cpp
index 2e74682fe32..9fba99a9ac1 100644
--- a/src/mongo/db/query/query_yield.cpp
+++ b/src/mongo/db/query/query_yield.cpp
@@ -26,6 +26,8 @@
* it in the license file.
*/
+#include "mongo/platform/basic.h"
+
#include "mongo/db/query/query_yield.h"
#include "mongo/db/curop.h"
diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript
index 14afac08cdf..f6fa162790b 100644
--- a/src/mongo/db/repl/SConscript
+++ b/src/mongo/db/repl/SConscript
@@ -80,10 +80,11 @@ env.Library('repl_coordinator_impl',
'check_quorum_for_config_change.cpp',
'elect_cmd_runner.cpp',
'freshness_checker.cpp',
+ 'repl_client_info.cpp',
+ 'replica_set_config_checks.cpp',
'replication_coordinator_impl.cpp',
'replication_coordinator_impl_elect.cpp',
'replication_coordinator_impl_heartbeat.cpp',
- 'replica_set_config_checks.cpp',
],
LIBDEPS=[
'$BUILD_DIR/mongo/db/common',
diff --git a/src/mongo/db/repl/master_slave.cpp b/src/mongo/db/repl/master_slave.cpp
index 3c7c14d0ee8..b0ab3cb5037 100644
--- a/src/mongo/db/repl/master_slave.cpp
+++ b/src/mongo/db/repl/master_slave.cpp
@@ -61,6 +61,7 @@
#include "mongo/db/operation_context_impl.h"
#include "mongo/db/ops/update.h"
#include "mongo/db/query/internal_plans.h"
+#include "mongo/db/repl/repl_client_info.h"
#include "mongo/db/repl/handshake_args.h"
#include "mongo/db/repl/oplog.h"
#include "mongo/db/repl/replication_coordinator_global.h"
@@ -381,7 +382,7 @@ namespace repl {
return appendCommandStatus(result, status);
}
- txn->getClient()->setRemoteID(handshake.getRid());
+ ReplClientInfo::forClient(txn->getClient()).setRemoteID(handshake.getRid());
status = getGlobalReplicationCoordinator()->processHandshake(txn, handshake);
return appendCommandStatus(result, status);
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index 8f3bbe52de5..ae387139c9a 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -61,6 +61,7 @@
#include "mongo/db/ops/update.h"
#include "mongo/db/ops/update_lifecycle_impl.h"
#include "mongo/db/repl/bgsync.h"
+#include "mongo/db/repl/repl_client_info.h"
#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/stats/counters.h"
#include "mongo/db/storage/storage_engine.h"
@@ -292,11 +293,10 @@ namespace {
OplogDocWriter writer( partial, obj );
checkOplogInsert( _localOplogCollection->insertDocument( txn, &writer, false ) );
- txn->getClient()->setLastOp( slot.first );
+ ReplClientInfo::forClient(txn->getClient()).setLastOp( slot.first );
}
- OpTime writeOpsToOplog(OperationContext* txn,
- const std::deque<BSONObj>& ops) {
+ OpTime writeOpsToOplog(OperationContext* txn, const std::deque<BSONObj>& ops) {
ReplicationCoordinator* replCoord = getGlobalReplicationCoordinator();
OpTime lastOptime = replCoord->getMyLastOptime();
invariant(!ops.empty());
diff --git a/src/mongo/db/repl/repl_client_info.cpp b/src/mongo/db/repl/repl_client_info.cpp
new file mode 100644
index 00000000000..2f8a1e72470
--- /dev/null
+++ b/src/mongo/db/repl/repl_client_info.cpp
@@ -0,0 +1,45 @@
+/**
+ * Copyright (C) 2015 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the GNU Affero General Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+#include "mongo/platform/basic.h"
+
+#include "mongo/db/repl/repl_client_info.h"
+
+#include "mongo/base/init.h"
+#include "mongo/db/client.h"
+#include "mongo/db/jsobj.h"
+#include "mongo/util/decorable.h"
+
+namespace mongo {
+namespace repl {
+
+ const Client::Decoration<ReplClientInfo> ReplClientInfo::forClient =
+ Client::declareDecoration<ReplClientInfo>();
+
+} // namespace repl
+} // namespace mongo
diff --git a/src/mongo/db/repl/repl_client_info.h b/src/mongo/db/repl/repl_client_info.h
new file mode 100644
index 00000000000..3aa0c73b66f
--- /dev/null
+++ b/src/mongo/db/repl/repl_client_info.h
@@ -0,0 +1,59 @@
+/**
+ * Copyright (C) 2015 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/bson/oid.h"
+#include "mongo/bson/optime.h"
+#include "mongo/db/client.h"
+
+namespace mongo {
+
+ class BSONObjBuilder;
+ class Client;
+
+namespace repl {
+
+ class ReplClientInfo {
+ public:
+ static const Client::Decoration<ReplClientInfo> forClient;
+
+ void setLastOp(OpTime op) { _lastOp = op; }
+ OpTime getLastOp() const { return _lastOp; }
+
+ // Only used for master/slave
+ void setRemoteID(OID rid) { _remoteId = rid; }
+ OID getRemoteID() const { return _remoteId; }
+
+ private:
+ OpTime _lastOp = OpTime();
+ OID _remoteId = OID();
+ };
+
+} // namespace repl
+} // namespace mongo
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp
index b5862803088..3ee5b1227ea 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl.cpp
@@ -45,6 +45,7 @@
#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/repl_client_info.h"
#include "mongo/db/repl/repl_set_heartbeat_args.h"
#include "mongo/db/repl/repl_set_heartbeat_response.h"
#include "mongo/db/repl/repl_settings.h"
@@ -912,7 +913,11 @@ namespace {
Timer timer;
boost::unique_lock<boost::mutex> lock(_mutex);
return _awaitReplication_inlock(
- &timer, &lock, txn, txn->getClient()->getLastOp(), writeConcern);
+ &timer,
+ &lock,
+ txn,
+ ReplClientInfo::forClient(txn->getClient()).getLastOp(),
+ writeConcern);
}
ReplicationCoordinator::StatusAndDuration ReplicationCoordinatorImpl::_awaitReplication_inlock(
diff --git a/src/mongo/db/repl/rs_initialsync.cpp b/src/mongo/db/repl/rs_initialsync.cpp
index be6525bd850..6fdf3e72190 100644
--- a/src/mongo/db/repl/rs_initialsync.cpp
+++ b/src/mongo/db/repl/rs_initialsync.cpp
@@ -50,6 +50,7 @@
#include "mongo/db/repl/minvalid.h"
#include "mongo/db/repl/oplog.h"
#include "mongo/db/repl/oplogreader.h"
+#include "mongo/db/repl/repl_client_info.h"
#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/util/exit.h"
#include "mongo/util/log.h"
@@ -391,7 +392,7 @@ namespace {
ops.push_back(lastOp);
OpTime lastOptime = writeOpsToOplog(&txn, ops);
- txn.getClient()->setLastOp(lastOptime);
+ ReplClientInfo::forClient(txn.getClient()).setLastOp(lastOptime);
replCoord->setMyLastOptime(lastOptime);
setNewOptime(lastOptime);
diff --git a/src/mongo/db/repl/sync_tail.cpp b/src/mongo/db/repl/sync_tail.cpp
index 2a3e299a62c..7b6349a1738 100644
--- a/src/mongo/db/repl/sync_tail.cpp
+++ b/src/mongo/db/repl/sync_tail.cpp
@@ -52,6 +52,7 @@
#include "mongo/db/repl/bgsync.h"
#include "mongo/db/repl/minvalid.h"
#include "mongo/db/repl/oplog.h"
+#include "mongo/db/repl/repl_client_info.h"
#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/stats/timer_stats.h"
#include "mongo/util/exit.h"
@@ -307,7 +308,7 @@ namespace repl {
if (mustAwaitCommit) {
txn->recoveryUnit()->awaitCommit();
}
- txn->getClient()->setLastOp(lastOpTime);
+ ReplClientInfo::forClient(txn->getClient()).setLastOp(lastOpTime);
replCoord->setMyLastOptime(lastOpTime);
setNewOptime(lastOpTime);
diff --git a/src/mongo/dbtests/query_stage_ixscan.cpp b/src/mongo/dbtests/query_stage_ixscan.cpp
index c0db9cbc1ed..b5aadc755d2 100644
--- a/src/mongo/dbtests/query_stage_ixscan.cpp
+++ b/src/mongo/dbtests/query_stage_ixscan.cpp
@@ -26,6 +26,8 @@
* it in the license file.
*/
+#include "mongo/platform/basic.h"
+
#include "mongo/db/client.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/exec/index_scan.h"
diff --git a/src/mongo/s/d_migrate.cpp b/src/mongo/s/d_migrate.cpp
index 77482a082fd..a9a3d2b2571 100644
--- a/src/mongo/s/d_migrate.cpp
+++ b/src/mongo/s/d_migrate.cpp
@@ -70,6 +70,7 @@
#include "mongo/db/query/internal_plans.h"
#include "mongo/db/query/query_knobs.h"
#include "mongo/db/range_deleter_service.h"
+#include "mongo/db/repl/repl_client_info.h"
#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/storage/mmap_v1/dur.h"
#include "mongo/db/write_concern.h"
@@ -2200,7 +2201,8 @@ namespace mongo {
repl::ReplicationCoordinator::StatusAndDuration replStatus =
repl::getGlobalReplicationCoordinator()->awaitReplication(
txn,
- txn->getClient()->getLastOp(),
+ repl::ReplClientInfo::forClient(
+ txn->getClient()).getLastOp(),
writeConcern);
if (replStatus.status.code() == ErrorCodes::ExceededTimeLimit) {
warning() << "secondaryThrottle on, but doc insert timed out; "
@@ -2221,7 +2223,8 @@ namespace mongo {
}
// if running on a replicated system, we'll need to flush the docs we cloned to the secondaries
- OpTime lastOpApplied = txn->getClient()->getLastOp();
+
+ OpTime lastOpApplied = repl::ReplClientInfo::forClient(txn->getClient()).getLastOp();
{
// 4. do bulk of mods
@@ -2436,7 +2439,7 @@ namespace mongo {
false /* god */,
true /* fromMigrate */);
- *lastOpApplied = txn->getClient()->getLastOp();
+ *lastOpApplied = repl::ReplClientInfo::forClient(txn->getClient()).getLastOp();
didAnything = true;
}
}
@@ -2472,7 +2475,7 @@ namespace mongo {
// We are in write lock here, so sure we aren't killing
Helpers::upsert( txn, ns , updatedDoc , true );
- *lastOpApplied = txn->getClient()->getLastOp();
+ *lastOpApplied = repl::ReplClientInfo::forClient(txn->getClient()).getLastOp();
didAnything = true;
}
}
diff --git a/src/mongo/s/s_only.cpp b/src/mongo/s/s_only.cpp
index edcb60cdffb..a3aad1f2a44 100644
--- a/src/mongo/s/s_only.cpp
+++ b/src/mongo/s/s_only.cpp
@@ -64,7 +64,6 @@ namespace mongo {
_desc(desc),
_connectionId(),
_inDirectClient(false),
- _lastOp(0),
_shutdown(false) {
}
Client::~Client() {}