summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/s/client/SConscript2
-rw-r--r--src/mongo/s/client/shard_connection.cpp14
-rw-r--r--src/mongo/s/d_state.cpp2
-rw-r--r--src/mongo/s/s_only.cpp9
4 files changed, 11 insertions, 16 deletions
diff --git a/src/mongo/s/client/SConscript b/src/mongo/s/client/SConscript
index 573d7a5c70b..6719c2cb248 100644
--- a/src/mongo/s/client/SConscript
+++ b/src/mongo/s/client/SConscript
@@ -19,6 +19,8 @@ env.Library(
'$BUILD_DIR/mongo/executor/connection_pool_stats',
'$BUILD_DIR/mongo/executor/task_executor_pool',
'$BUILD_DIR/mongo/rpc/metadata',
+ '$BUILD_DIR/mongo/s/cluster_last_error_info',
+ '$BUILD_DIR/mongo/s/is_mongos',
'shard_interface',
],
LIBDEPS_TAGS=[
diff --git a/src/mongo/s/client/shard_connection.cpp b/src/mongo/s/client/shard_connection.cpp
index 7e38ed59b9e..bbe562997c1 100644
--- a/src/mongo/s/client/shard_connection.cpp
+++ b/src/mongo/s/client/shard_connection.cpp
@@ -41,7 +41,9 @@
#include "mongo/s/client/shard.h"
#include "mongo/s/client/shard_registry.h"
#include "mongo/s/client/version_manager.h"
+#include "mongo/s/cluster_last_error_info.h"
#include "mongo/s/grid.h"
+#include "mongo/s/is_mongos.h"
#include "mongo/util/concurrency/spin_lock.h"
#include "mongo/util/exit.h"
#include "mongo/util/log.h"
@@ -401,9 +403,6 @@ thread_specific_ptr<ClientConnections> ClientConnections::_perThread;
// The global connection pool
DBConnectionPool shardConnectionPool;
-// Different between mongos and mongod
-void usingAShardConnection(const string& addr);
-
ShardConnection::ShardConnection(const ConnectionString& connectionString,
const string& ns,
std::shared_ptr<ChunkManager> manager)
@@ -415,8 +414,13 @@ ShardConnection::ShardConnection(const ConnectionString& connectionString,
invariant(_manager->getns() == _ns);
}
- _conn = ClientConnections::threadInstance()->get(_cs.toString(), _ns);
- usingAShardConnection(_cs.toString());
+ auto csString = _cs.toString();
+ _conn = ClientConnections::threadInstance()->get(csString, _ns);
+ if (isMongos()) {
+ // In mongos, we record this connection as having been used for useful work to provide
+ // useful information in getLastError.
+ ClusterLastErrorInfo::get(cc()).addShardHost(csString);
+ }
}
ShardConnection::~ShardConnection() {
diff --git a/src/mongo/s/d_state.cpp b/src/mongo/s/d_state.cpp
index 3f3d9dc08b1..41960a35ba0 100644
--- a/src/mongo/s/d_state.cpp
+++ b/src/mongo/s/d_state.cpp
@@ -84,6 +84,4 @@ MONGO_INITIALIZER_WITH_PREREQUISITES(MongoDLocalShardingInfo, ("SetGlobalEnviron
} // namespace
-void usingAShardConnection(const string& addr) {}
-
} // namespace mongo
diff --git a/src/mongo/s/s_only.cpp b/src/mongo/s/s_only.cpp
index e012c9045a5..d9475872961 100644
--- a/src/mongo/s/s_only.cpp
+++ b/src/mongo/s/s_only.cpp
@@ -45,7 +45,6 @@
#include "mongo/rpc/metadata/tracking_metadata.h"
#include "mongo/rpc/reply_builder_interface.h"
#include "mongo/rpc/request_interface.h"
-#include "mongo/s/cluster_last_error_info.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/concurrency/thread_name.h"
#include "mongo/util/log.h"
@@ -56,14 +55,6 @@ namespace mongo {
using std::string;
using std::stringstream;
-/**
- * When this callback is run, we record a shard that we've used for useful work in an operation to
- * be read later by getLastError()
- */
-void usingAShardConnection(const std::string& addr) {
- ClusterLastErrorInfo::get(cc()).addShardHost(addr);
-}
-
// called into by the web server. For now we just translate the parameters
// to their old style equivalents.
void Command::execCommand(OperationContext* txn,