summaryrefslogtreecommitdiff
path: root/src/mongo/s/commands
diff options
context:
space:
mode:
authorSpencer T Brody <spencer@mongodb.com>2015-08-19 17:14:33 -0400
committerSpencer T Brody <spencer@mongodb.com>2015-08-25 12:56:28 -0400
commitf415aad16ec26a89110a71232dc898218dc5d85c (patch)
tree14cae84b235c52981d8d661b5219d02aab193cf0 /src/mongo/s/commands
parenteb0430ee860d22b164cd603ce7186842f72c8537 (diff)
downloadmongo-f415aad16ec26a89110a71232dc898218dc5d85c.tar.gz
SERVER-19875 Add OperationContext to CatalogManager::getAllShards
Diffstat (limited to 'src/mongo/s/commands')
-rw-r--r--src/mongo/s/commands/cluster_count_cmd.cpp2
-rw-r--r--src/mongo/s/commands/cluster_find_and_modify_cmd.cpp17
-rw-r--r--src/mongo/s/commands/cluster_find_cmd.cpp2
-rw-r--r--src/mongo/s/commands/cluster_fsync_cmd.cpp2
-rw-r--r--src/mongo/s/commands/cluster_kill_op.cpp2
-rw-r--r--src/mongo/s/commands/cluster_list_databases_cmd.cpp2
-rw-r--r--src/mongo/s/commands/cluster_list_shards_cmd.cpp2
-rw-r--r--src/mongo/s/commands/cluster_map_reduce_cmd.cpp9
-rw-r--r--src/mongo/s/commands/cluster_merge_chunks_cmd.cpp2
-rw-r--r--src/mongo/s/commands/cluster_move_chunk_cmd.cpp4
-rw-r--r--src/mongo/s/commands/cluster_move_primary_cmd.cpp4
-rw-r--r--src/mongo/s/commands/cluster_pipeline_cmd.cpp14
-rw-r--r--src/mongo/s/commands/cluster_remove_shard_cmd.cpp2
-rw-r--r--src/mongo/s/commands/cluster_shard_collection_cmd.cpp4
-rw-r--r--src/mongo/s/commands/cluster_write_cmd.cpp6
-rw-r--r--src/mongo/s/commands/commands_public.cpp74
-rw-r--r--src/mongo/s/commands/run_on_all_shards_cmd.cpp2
17 files changed, 80 insertions, 70 deletions
diff --git a/src/mongo/s/commands/cluster_count_cmd.cpp b/src/mongo/s/commands/cluster_count_cmd.cpp
index 3253afc6ba2..4c3146d9659 100644
--- a/src/mongo/s/commands/cluster_count_cmd.cpp
+++ b/src/mongo/s/commands/cluster_count_cmd.cpp
@@ -221,7 +221,7 @@ public:
const char* mongosStageName = ClusterExplain::getStageNameForReadOp(shardResults, cmdObj);
return ClusterExplain::buildExplainResult(
- shardResults, mongosStageName, millisElapsed, out);
+ txn, shardResults, mongosStageName, millisElapsed, out);
}
} clusterCountCmd;
diff --git a/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp b/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp
index fe9ab7787d5..120af9b345b 100644
--- a/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp
+++ b/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp
@@ -90,7 +90,7 @@ public:
shared_ptr<Shard> shard;
if (!conf->isShardingEnabled() || !conf->isSharded(ns)) {
- shard = grid.shardRegistry()->getShard(conf->getPrimaryId());
+ shard = grid.shardRegistry()->getShard(txn, conf->getPrimaryId());
} else {
shared_ptr<ChunkManager> chunkMgr = _getChunkManager(txn, conf, ns);
@@ -104,7 +104,7 @@ public:
BSONObj shardKey = status.getValue();
ChunkPtr chunk = chunkMgr->findIntersectingChunk(txn, shardKey);
- shard = grid.shardRegistry()->getShard(chunk->getShardId());
+ shard = grid.shardRegistry()->getShard(txn, chunk->getShardId());
}
BSONObjBuilder explainCmd;
@@ -114,7 +114,7 @@ public:
Timer timer;
BSONObjBuilder result;
- bool ok = _runCommand(conf, shard->getId(), ns, explainCmd.obj(), result);
+ bool ok = _runCommand(txn, conf, shard->getId(), ns, explainCmd.obj(), result);
long long millisElapsed = timer.millis();
if (!ok) {
@@ -132,7 +132,7 @@ public:
shardResults.push_back(cmdResult);
return ClusterExplain::buildExplainResult(
- shardResults, ClusterExplain::kSingleShard, millisElapsed, out);
+ txn, shardResults, ClusterExplain::kSingleShard, millisElapsed, out);
}
virtual bool run(OperationContext* txn,
@@ -147,7 +147,7 @@ public:
// require that the parsing be pulled into this function.
auto conf = uassertStatusOK(grid.implicitCreateDb(txn, dbName));
if (!conf->isShardingEnabled() || !conf->isSharded(ns)) {
- return _runCommand(conf, conf->getPrimaryId(), ns, cmdObj, result);
+ return _runCommand(txn, conf, conf->getPrimaryId(), ns, cmdObj, result);
}
shared_ptr<ChunkManager> chunkMgr = _getChunkManager(txn, conf, ns);
@@ -163,7 +163,7 @@ public:
BSONObj shardKey = status.getValue();
ChunkPtr chunk = chunkMgr->findIntersectingChunk(txn, shardKey);
- bool ok = _runCommand(conf, chunk->getShardId(), ns, cmdObj, result);
+ bool ok = _runCommand(txn, conf, chunk->getShardId(), ns, cmdObj, result);
if (ok) {
// check whether split is necessary (using update object for size heuristic)
if (Chunk::ShouldAutoSplit) {
@@ -203,14 +203,15 @@ private:
return shardKey;
}
- bool _runCommand(shared_ptr<DBConfig> conf,
+ bool _runCommand(OperationContext* txn,
+ shared_ptr<DBConfig> conf,
const ShardId& shardId,
const string& ns,
const BSONObj& cmdObj,
BSONObjBuilder& result) const {
BSONObj res;
- const auto shard = grid.shardRegistry()->getShard(shardId);
+ const auto shard = grid.shardRegistry()->getShard(txn, shardId);
ShardConnection conn(shard->getConnString(), ns);
bool ok = conn->runCommand(conf->name(), cmdObj, res);
conn.done();
diff --git a/src/mongo/s/commands/cluster_find_cmd.cpp b/src/mongo/s/commands/cluster_find_cmd.cpp
index 6a884e372e3..e38bca1334b 100644
--- a/src/mongo/s/commands/cluster_find_cmd.cpp
+++ b/src/mongo/s/commands/cluster_find_cmd.cpp
@@ -143,7 +143,7 @@ public:
const char* mongosStageName = ClusterExplain::getStageNameForReadOp(shardResults, cmdObj);
return ClusterExplain::buildExplainResult(
- shardResults, mongosStageName, millisElapsed, out);
+ txn, shardResults, mongosStageName, millisElapsed, out);
}
bool run(OperationContext* txn,
diff --git a/src/mongo/s/commands/cluster_fsync_cmd.cpp b/src/mongo/s/commands/cluster_fsync_cmd.cpp
index 90735a25784..34098d450d6 100644
--- a/src/mongo/s/commands/cluster_fsync_cmd.cpp
+++ b/src/mongo/s/commands/cluster_fsync_cmd.cpp
@@ -86,7 +86,7 @@ public:
grid.shardRegistry()->getAllShardIds(&shardIds);
for (const ShardId& shardId : shardIds) {
- const auto s = grid.shardRegistry()->getShard(shardId);
+ const auto s = grid.shardRegistry()->getShard(txn, shardId);
if (!s) {
continue;
}
diff --git a/src/mongo/s/commands/cluster_kill_op.cpp b/src/mongo/s/commands/cluster_kill_op.cpp
index 056f4b7ff60..d99abb461f0 100644
--- a/src/mongo/s/commands/cluster_kill_op.cpp
+++ b/src/mongo/s/commands/cluster_kill_op.cpp
@@ -99,7 +99,7 @@ public:
log() << "want to kill op: " << opToKill;
// Will throw if shard id is not found
- auto shard = grid.shardRegistry()->getShard(shardIdent);
+ auto shard = grid.shardRegistry()->getShard(txn, shardIdent);
if (!shard) {
return appendCommandStatus(
result,
diff --git a/src/mongo/s/commands/cluster_list_databases_cmd.cpp b/src/mongo/s/commands/cluster_list_databases_cmd.cpp
index 0878123bc39..fc2ea7b22f0 100644
--- a/src/mongo/s/commands/cluster_list_databases_cmd.cpp
+++ b/src/mongo/s/commands/cluster_list_databases_cmd.cpp
@@ -94,7 +94,7 @@ public:
grid.shardRegistry()->getAllShardIds(&shardIds);
for (const ShardId& shardId : shardIds) {
- const auto s = grid.shardRegistry()->getShard(shardId);
+ const auto s = grid.shardRegistry()->getShard(txn, shardId);
if (!s) {
continue;
}
diff --git a/src/mongo/s/commands/cluster_list_shards_cmd.cpp b/src/mongo/s/commands/cluster_list_shards_cmd.cpp
index da852b42ee7..dedbc136726 100644
--- a/src/mongo/s/commands/cluster_list_shards_cmd.cpp
+++ b/src/mongo/s/commands/cluster_list_shards_cmd.cpp
@@ -74,7 +74,7 @@ public:
std::string& errmsg,
BSONObjBuilder& result) {
std::vector<ShardType> shards;
- Status status = grid.catalogManager(txn)->getAllShards(&shards);
+ Status status = grid.catalogManager(txn)->getAllShards(txn, &shards);
if (!status.isOK()) {
return appendCommandStatus(result, status);
}
diff --git a/src/mongo/s/commands/cluster_map_reduce_cmd.cpp b/src/mongo/s/commands/cluster_map_reduce_cmd.cpp
index 728ebc76bd7..3c942c5e89e 100644
--- a/src/mongo/s/commands/cluster_map_reduce_cmd.cpp
+++ b/src/mongo/s/commands/cluster_map_reduce_cmd.cpp
@@ -266,7 +266,7 @@ public:
if (!shardedInput && !shardedOutput && !customOutDB) {
LOG(1) << "simple MR, just passthrough";
- const auto shard = grid.shardRegistry()->getShard(confIn->getPrimaryId());
+ const auto shard = grid.shardRegistry()->getShard(txn, confIn->getPrimaryId());
ShardConnection conn(shard->getConnString(), "");
BSONObj res;
@@ -312,7 +312,7 @@ public:
// Need to gather list of all servers even if an error happened
string server;
{
- const auto shard = grid.shardRegistry()->getShard(mrResult.shardTargetId);
+ const auto shard = grid.shardRegistry()->getShard(txn, mrResult.shardTargetId);
server = shard->getConnString().toString();
}
servers.insert(server);
@@ -403,7 +403,7 @@ public:
BSONObj singleResult;
if (!shardedOutput) {
- const auto shard = grid.shardRegistry()->getShard(confOut->getPrimaryId());
+ const auto shard = grid.shardRegistry()->getShard(txn, confOut->getPrimaryId());
LOG(1) << "MR with single shard output, NS=" << finalColLong
<< " primary=" << shard->toString();
@@ -481,7 +481,8 @@ public:
for (const auto& mrResult : mrCommandResults) {
string server;
{
- const auto shard = grid.shardRegistry()->getShard(mrResult.shardTargetId);
+ const auto shard =
+ grid.shardRegistry()->getShard(txn, mrResult.shardTargetId);
server = shard->getConnString().toString();
}
singleResult = mrResult.result;
diff --git a/src/mongo/s/commands/cluster_merge_chunks_cmd.cpp b/src/mongo/s/commands/cluster_merge_chunks_cmd.cpp
index 2c3802a8f3b..f040fafa4c6 100644
--- a/src/mongo/s/commands/cluster_merge_chunks_cmd.cpp
+++ b/src/mongo/s/commands/cluster_merge_chunks_cmd.cpp
@@ -183,7 +183,7 @@ public:
// Throws, but handled at level above. Don't want to rewrap to preserve exception
// formatting.
- const auto shard = grid.shardRegistry()->getShard(firstChunk->getShardId());
+ const auto shard = grid.shardRegistry()->getShard(txn, firstChunk->getShardId());
if (!shard) {
return appendCommandStatus(
result,
diff --git a/src/mongo/s/commands/cluster_move_chunk_cmd.cpp b/src/mongo/s/commands/cluster_move_chunk_cmd.cpp
index 9dc54bb633c..8f033427b6e 100644
--- a/src/mongo/s/commands/cluster_move_chunk_cmd.cpp
+++ b/src/mongo/s/commands/cluster_move_chunk_cmd.cpp
@@ -140,7 +140,7 @@ public:
return false;
}
- const auto to = grid.shardRegistry()->getShard(toString);
+ const auto to = grid.shardRegistry()->getShard(txn, toString);
if (!to) {
string msg(str::stream() << "Could not move chunk in '" << nss.ns() << "' to shard '"
<< toString << "' because that shard does not exist");
@@ -208,7 +208,7 @@ public:
}
{
- const auto from = grid.shardRegistry()->getShard(chunk->getShardId());
+ const auto from = grid.shardRegistry()->getShard(txn, chunk->getShardId());
if (from->getId() == to->getId()) {
errmsg = "that chunk is already on that shard";
return false;
diff --git a/src/mongo/s/commands/cluster_move_primary_cmd.cpp b/src/mongo/s/commands/cluster_move_primary_cmd.cpp
index dff18f954c2..2736a962a9c 100644
--- a/src/mongo/s/commands/cluster_move_primary_cmd.cpp
+++ b/src/mongo/s/commands/cluster_move_primary_cmd.cpp
@@ -126,7 +126,7 @@ public:
return false;
}
- shared_ptr<Shard> toShard = grid.shardRegistry()->getShard(to);
+ shared_ptr<Shard> toShard = grid.shardRegistry()->getShard(txn, to);
if (!toShard) {
string msg(str::stream() << "Could not move database '" << dbname << "' to shard '"
<< to << "' because the shard does not exist");
@@ -134,7 +134,7 @@ public:
return appendCommandStatus(result, Status(ErrorCodes::ShardNotFound, msg));
}
- shared_ptr<Shard> fromShard = grid.shardRegistry()->getShard(config->getPrimaryId());
+ shared_ptr<Shard> fromShard = grid.shardRegistry()->getShard(txn, config->getPrimaryId());
invariant(fromShard);
if (fromShard->getConnString().sameLogicalEndpoint(toShard->getConnString())) {
diff --git a/src/mongo/s/commands/cluster_pipeline_cmd.cpp b/src/mongo/s/commands/cluster_pipeline_cmd.cpp
index ce272013709..820fa945ad9 100644
--- a/src/mongo/s/commands/cluster_pipeline_cmd.cpp
+++ b/src/mongo/s/commands/cluster_pipeline_cmd.cpp
@@ -110,7 +110,7 @@ public:
shared_ptr<DBConfig> conf = status.getValue();
if (!conf->isShardingEnabled()) {
- return aggPassthrough(conf, cmdObj, result, options);
+ return aggPassthrough(txn, conf, cmdObj, result, options);
}
intrusive_ptr<ExpressionContext> mergeCtx =
@@ -131,7 +131,7 @@ public:
}
if (!conf->isSharded(fullns)) {
- return aggPassthrough(conf, cmdObj, result, options);
+ return aggPassthrough(txn, conf, cmdObj, result, options);
}
// If the first $match stage is an exact match on the shard key, we only have to send it
@@ -234,7 +234,7 @@ public:
const auto& mergingShardId = needPrimaryShardMerger
? conf->getPrimaryId()
: shardResults[prng.nextInt32(shardResults.size())].shardTargetId;
- const auto mergingShard = grid.shardRegistry()->getShard(mergingShardId);
+ const auto mergingShard = grid.shardRegistry()->getShard(txn, mergingShardId);
ShardConnection conn(mergingShard->getConnString(), outputNsOrEmpty);
BSONObj mergedResults =
aggRunCommand(conn.get(), dbname, mergeCmd.freeze().toBson(), options);
@@ -261,7 +261,8 @@ private:
// returned cursors with mongos's cursorCache.
BSONObj aggRunCommand(DBClientBase* conn, const string& db, BSONObj cmd, int queryOptions);
- bool aggPassthrough(shared_ptr<DBConfig> conf,
+ bool aggPassthrough(OperationContext* txn,
+ shared_ptr<DBConfig> conf,
BSONObj cmd,
BSONObjBuilder& result,
int queryOptions);
@@ -398,12 +399,13 @@ BSONObj PipelineCommand::aggRunCommand(DBClientBase* conn,
return result;
}
-bool PipelineCommand::aggPassthrough(shared_ptr<DBConfig> conf,
+bool PipelineCommand::aggPassthrough(OperationContext* txn,
+ shared_ptr<DBConfig> conf,
BSONObj cmd,
BSONObjBuilder& out,
int queryOptions) {
// Temporary hack. See comment on declaration for details.
- const auto shard = grid.shardRegistry()->getShard(conf->getPrimaryId());
+ const auto shard = grid.shardRegistry()->getShard(txn, conf->getPrimaryId());
ShardConnection conn(shard->getConnString(), "");
BSONObj result = aggRunCommand(conn.get(), conf->name(), cmd, queryOptions);
conn.done();
diff --git a/src/mongo/s/commands/cluster_remove_shard_cmd.cpp b/src/mongo/s/commands/cluster_remove_shard_cmd.cpp
index a9ad5bd122d..c225bfa2f55 100644
--- a/src/mongo/s/commands/cluster_remove_shard_cmd.cpp
+++ b/src/mongo/s/commands/cluster_remove_shard_cmd.cpp
@@ -86,7 +86,7 @@ public:
BSONObjBuilder& result) {
const string target = cmdObj.firstElement().valuestrsafe();
- const auto s = grid.shardRegistry()->getShard(target);
+ const auto s = grid.shardRegistry()->getShard(txn, target);
if (!s) {
string msg(str::stream() << "Could not drop shard '" << target
<< "' because it does not exist");
diff --git a/src/mongo/s/commands/cluster_shard_collection_cmd.cpp b/src/mongo/s/commands/cluster_shard_collection_cmd.cpp
index c84946580f4..9a7cfa376c0 100644
--- a/src/mongo/s/commands/cluster_shard_collection_cmd.cpp
+++ b/src/mongo/s/commands/cluster_shard_collection_cmd.cpp
@@ -171,7 +171,7 @@ public:
// The rest of the checks require a connection to the primary db
ConnectionString shardConnString;
{
- const auto shard = grid.shardRegistry()->getShard(config->getPrimaryId());
+ const auto shard = grid.shardRegistry()->getShard(txn, config->getPrimaryId());
shardConnString = shard->getConnString();
}
@@ -416,7 +416,7 @@ public:
int i = 0;
for (ChunkMap::const_iterator c = chunkMap.begin(); c != chunkMap.end(); ++c, ++i) {
const ShardId& shardId = shardIds[i % numShards];
- const auto to = grid.shardRegistry()->getShard(shardId);
+ const auto to = grid.shardRegistry()->getShard(txn, shardId);
if (!to) {
continue;
}
diff --git a/src/mongo/s/commands/cluster_write_cmd.cpp b/src/mongo/s/commands/cluster_write_cmd.cpp
index cea3c22307b..2a7176339fe 100644
--- a/src/mongo/s/commands/cluster_write_cmd.cpp
+++ b/src/mongo/s/commands/cluster_write_cmd.cpp
@@ -126,7 +126,7 @@ public:
}
return ClusterExplain::buildExplainResult(
- shardResults, ClusterExplain::kWriteOnShards, timer.millis(), out);
+ txn, shardResults, ClusterExplain::kWriteOnShards, timer.millis(), out);
}
virtual bool run(OperationContext* txn,
@@ -265,7 +265,7 @@ private:
const ShardEndpoint* endpoint = *it;
ConnectionString host;
- Status status = resolver.chooseWriteHost(endpoint->shardName, &host);
+ Status status = resolver.chooseWriteHost(txn, endpoint->shardName, &host);
if (!status.isOK())
return status;
@@ -291,7 +291,7 @@ private:
Strategy::CommandResult result;
result.target = host;
{
- const auto shard = grid.shardRegistry()->getShard(host.toString());
+ const auto shard = grid.shardRegistry()->getShard(txn, host.toString());
result.shardTargetId = shard->getId();
}
result.result = response.toBSON();
diff --git a/src/mongo/s/commands/commands_public.cpp b/src/mongo/s/commands/commands_public.cpp
index 65ebfe77ad5..6a404bad604 100644
--- a/src/mongo/s/commands/commands_public.cpp
+++ b/src/mongo/s/commands/commands_public.cpp
@@ -100,30 +100,36 @@ public:
}
protected:
- bool passthrough(shared_ptr<DBConfig> conf, const BSONObj& cmdObj, BSONObjBuilder& result) {
- return _passthrough(conf->name(), conf, cmdObj, 0, result);
+ bool passthrough(OperationContext* txn,
+ shared_ptr<DBConfig> conf,
+ const BSONObj& cmdObj,
+ BSONObjBuilder& result) {
+ return _passthrough(txn, conf->name(), conf, cmdObj, 0, result);
}
- bool adminPassthrough(shared_ptr<DBConfig> conf,
+ bool adminPassthrough(OperationContext* txn,
+ shared_ptr<DBConfig> conf,
const BSONObj& cmdObj,
BSONObjBuilder& result) {
- return _passthrough("admin", conf, cmdObj, 0, result);
+ return _passthrough(txn, "admin", conf, cmdObj, 0, result);
}
- bool passthrough(shared_ptr<DBConfig> conf,
+ bool passthrough(OperationContext* txn,
+ shared_ptr<DBConfig> conf,
const BSONObj& cmdObj,
int options,
BSONObjBuilder& result) {
- return _passthrough(conf->name(), conf, cmdObj, options, result);
+ return _passthrough(txn, conf->name(), conf, cmdObj, options, result);
}
private:
- bool _passthrough(const string& db,
+ bool _passthrough(OperationContext* txn,
+ const string& db,
shared_ptr<DBConfig> conf,
const BSONObj& cmdObj,
int options,
BSONObjBuilder& result) {
- const auto shard = grid.shardRegistry()->getShard(conf->getPrimaryId());
+ const auto shard = grid.shardRegistry()->getShard(txn, conf->getPrimaryId());
ShardConnection conn(shard->getConnString(), "");
BSONObj res;
@@ -155,7 +161,7 @@ public:
shared_ptr<DBConfig> conf = status.getValue();
if (!conf->isShardingEnabled() || !conf->isSharded(fullns)) {
- shardIds.push_back(conf->getShardId(fullns));
+ shardIds.push_back(conf->getShardId(txn, fullns));
} else {
grid.shardRegistry()->getAllShardIds(&shardIds);
}
@@ -177,7 +183,7 @@ public:
auto conf = uassertStatusOK(grid.catalogCache()->getDatabase(txn, dbName));
if (!conf->isSharded(fullns)) {
- return passthrough(conf, cmdObj, options, result);
+ return passthrough(txn, conf, cmdObj, options, result);
}
return appendCommandStatus(
@@ -407,7 +413,7 @@ public:
shared_ptr<DBConfig> conf = status.getValue();
- return passthrough(conf, cmdObj, result);
+ return passthrough(txn, conf, cmdObj, result);
}
} createCmd;
@@ -445,7 +451,7 @@ public:
const auto& db = status.getValue();
if (!db->isShardingEnabled() || !db->isSharded(fullns)) {
log() << "\tdrop going to do passthrough";
- return passthrough(db, cmdObj, result);
+ return passthrough(txn, db, cmdObj, result);
}
uassertStatusOK(grid.catalogManager(txn)->dropCollection(txn, NamespaceString(fullns)));
@@ -486,14 +492,14 @@ public:
uassert(13138, "You can't rename a sharded collection", !confFrom->isSharded(fullnsFrom));
uassert(13139, "You can't rename to a sharded collection", !confTo->isSharded(fullnsTo));
- const ShardId& shardTo = confTo->getShardId(fullnsTo);
- const ShardId& shardFrom = confFrom->getShardId(fullnsFrom);
+ const ShardId& shardTo = confTo->getShardId(txn, fullnsTo);
+ const ShardId& shardFrom = confFrom->getShardId(txn, fullnsFrom);
uassert(13137,
"Source and destination collections must be on same shard",
shardFrom == shardTo);
- return adminPassthrough(confFrom, cmdObj, result);
+ return adminPassthrough(txn, confFrom, cmdObj, result);
}
} renameCollectionCmd;
@@ -526,7 +532,7 @@ public:
const string fromhost = cmdObj.getStringField("fromhost");
if (!fromhost.empty()) {
- return adminPassthrough(confTo, cmdObj, result);
+ return adminPassthrough(txn, confTo, cmdObj, result);
} else {
const string fromdb = cmdObj.getStringField("fromdb");
uassert(13399, "need a fromdb argument", !fromdb.empty());
@@ -545,12 +551,12 @@ public:
}
{
- const auto& shard = grid.shardRegistry()->getShard(confFrom->getPrimaryId());
+ const auto& shard = grid.shardRegistry()->getShard(txn, confFrom->getPrimaryId());
b.append("fromhost", shard->getConnString().toString());
}
BSONObj fixed = b.obj();
- return adminPassthrough(confTo, fixed, result);
+ return adminPassthrough(txn, confTo, fixed, result);
}
}
@@ -580,7 +586,7 @@ public:
result.appendBool("sharded", false);
result.append("primary", conf->getPrimaryId());
- return passthrough(conf, cmdObj, result);
+ return passthrough(txn, conf, cmdObj, result);
}
result.appendBool("sharded", true);
@@ -603,7 +609,7 @@ public:
cm->getAllShardIds(&shardIds);
for (const ShardId& shardId : shardIds) {
- const auto shard = grid.shardRegistry()->getShard(shardId);
+ const auto shard = grid.shardRegistry()->getShard(txn, shardId);
if (!shard) {
continue;
}
@@ -741,7 +747,7 @@ public:
auto conf = uassertStatusOK(grid.catalogCache()->getDatabase(txn, dbName));
if (!conf->isShardingEnabled() || !conf->isSharded(fullns)) {
- return passthrough(conf, cmdObj, result);
+ return passthrough(txn, conf, cmdObj, result);
}
ChunkManagerPtr cm = conf->getChunkManager(txn, fullns);
@@ -772,7 +778,7 @@ public:
set<ShardId> shardIds;
cm->getShardIdsForRange(shardIds, min, max);
for (const ShardId& shardId : shardIds) {
- const auto shard = grid.shardRegistry()->getShard(shardId);
+ const auto shard = grid.shardRegistry()->getShard(txn, shardId);
if (!shard) {
continue;
}
@@ -859,7 +865,7 @@ public:
shardResults.push_back(singleResult);
return ClusterExplain::buildExplainResult(
- shardResults, ClusterExplain::kSingleShard, millisElapsed, out);
+ txn, shardResults, ClusterExplain::kSingleShard, millisElapsed, out);
}
} groupCmd;
@@ -931,7 +937,7 @@ public:
shared_ptr<DBConfig> conf = status.getValue();
if (!conf->isShardingEnabled() || !conf->isSharded(fullns)) {
- return passthrough(conf, cmdObj, options, result);
+ return passthrough(txn, conf, cmdObj, options, result);
}
ChunkManagerPtr cm = conf->getChunkManager(txn, fullns);
@@ -945,7 +951,7 @@ public:
int size = 32;
for (const ShardId& shardId : shardIds) {
- const auto shard = grid.shardRegistry()->getShard(shardId);
+ const auto shard = grid.shardRegistry()->getShard(txn, shardId);
if (!shard) {
continue;
}
@@ -1011,7 +1017,7 @@ public:
const char* mongosStageName = ClusterExplain::getStageNameForReadOp(shardResults, cmdObj);
return ClusterExplain::buildExplainResult(
- shardResults, mongosStageName, millisElapsed, out);
+ txn, shardResults, mongosStageName, millisElapsed, out);
}
} disinctCmd;
@@ -1046,7 +1052,7 @@ public:
auto conf = uassertStatusOK(grid.catalogCache()->getDatabase(txn, dbName));
if (!conf->isShardingEnabled() || !conf->isSharded(fullns)) {
- return passthrough(conf, cmdObj, result);
+ return passthrough(txn, conf, cmdObj, result);
}
ChunkManagerPtr cm = conf->getChunkManager(txn, fullns);
@@ -1174,7 +1180,7 @@ public:
auto conf = uassertStatusOK(grid.catalogCache()->getDatabase(txn, dbName));
if (!conf->isShardingEnabled() || !conf->isSharded(fullns)) {
- return passthrough(conf, cmdObj, options, result);
+ return passthrough(txn, conf, cmdObj, options, result);
}
ChunkManagerPtr cm = conf->getChunkManager(txn, fullns);
@@ -1193,7 +1199,7 @@ public:
list<shared_ptr<Future::CommandResult>> futures;
BSONArrayBuilder shardArray;
for (const ShardId& shardId : shardIds) {
- const auto shard = grid.shardRegistry()->getShard(shardId);
+ const auto shard = grid.shardRegistry()->getShard(txn, shardId);
if (!shard) {
continue;
}
@@ -1344,7 +1350,7 @@ public:
}
shared_ptr<DBConfig> conf = status.getValue();
- return passthrough(conf, cmdObj, result);
+ return passthrough(txn, conf, cmdObj, result);
}
} evalCmd;
@@ -1384,9 +1390,9 @@ public:
}
shared_ptr<DBConfig> conf = status.getValue();
- bool retval = passthrough(conf, cmdObj, result);
+ bool retval = passthrough(txn, conf, cmdObj, result);
- const auto shard = grid.shardRegistry()->getShard(conf->getPrimaryId());
+ const auto shard = grid.shardRegistry()->getShard(txn, conf->getPrimaryId());
Status storeCursorStatus =
storePossibleCursor(shard->getConnString().toString(), result.asTempObj());
if (!storeCursorStatus.isOK()) {
@@ -1416,9 +1422,9 @@ public:
string& errmsg,
BSONObjBuilder& result) {
auto conf = uassertStatusOK(grid.catalogCache()->getDatabase(txn, dbName));
- bool retval = passthrough(conf, cmdObj, result);
+ bool retval = passthrough(txn, conf, cmdObj, result);
- const auto shard = grid.shardRegistry()->getShard(conf->getPrimaryId());
+ const auto shard = grid.shardRegistry()->getShard(txn, conf->getPrimaryId());
Status storeCursorStatus =
storePossibleCursor(shard->getConnString().toString(), result.asTempObj());
if (!storeCursorStatus.isOK()) {
diff --git a/src/mongo/s/commands/run_on_all_shards_cmd.cpp b/src/mongo/s/commands/run_on_all_shards_cmd.cpp
index 91b10dd1db0..157c556d65a 100644
--- a/src/mongo/s/commands/run_on_all_shards_cmd.cpp
+++ b/src/mongo/s/commands/run_on_all_shards_cmd.cpp
@@ -86,7 +86,7 @@ bool RunOnAllShardsCommand::run(OperationContext* txn,
std::list<std::shared_ptr<Future::CommandResult>> futures;
for (const ShardId& shardId : shardIds) {
- const auto shard = grid.shardRegistry()->getShard(shardId);
+ const auto shard = grid.shardRegistry()->getShard(txn, shardId);
if (!shard) {
continue;
}