mirror of https://github.com/mongodb/mongo
SERVER-104175 Remove redundant dbName parameter from scatterGather functions (#35283)
GitOrigin-RevId: d6f3afd6dba3c104d988fbe8d2a4cfd9cd3305be
This commit is contained in:
parent
9f8a5dc5bd
commit
cbd69e13ae
|
|
@ -499,7 +499,6 @@ void ShardServerProcessInterface::createIndexesOnEmptyCollection(
|
|||
auto cmdObj = cmdBuilder.obj();
|
||||
auto shardResponses = scatterGatherVersionedTargetByRoutingTable(
|
||||
opCtx,
|
||||
ns.dbName(),
|
||||
ns,
|
||||
cri,
|
||||
cmdObj,
|
||||
|
|
|
|||
|
|
@ -1118,6 +1118,7 @@ DispatchShardPipelineResults dispatchTargetedShardPipeline(
|
|||
if (explain) {
|
||||
shardResults = gatherResponses(opCtx,
|
||||
expCtx->getNamespaceString().dbName(),
|
||||
expCtx->getNamespaceString(),
|
||||
readPref,
|
||||
Shard::RetryPolicy::kIdempotent,
|
||||
requests);
|
||||
|
|
|
|||
|
|
@ -1174,6 +1174,7 @@ void createCollectionOnShards(OperationContext* opCtx,
|
|||
if (!requests.empty()) {
|
||||
auto responses = gatherResponses(opCtx,
|
||||
nss.dbName(),
|
||||
nss,
|
||||
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
|
||||
Shard::RetryPolicy::kIdempotent,
|
||||
requests);
|
||||
|
|
|
|||
|
|
@ -159,7 +159,6 @@ void SessionsCollectionConfigServer::_generateIndexesIfNeeded(OperationContext*
|
|||
|
||||
return scatterGatherVersionedTargetByRoutingTable(
|
||||
opCtx,
|
||||
nss.dbName(),
|
||||
nss,
|
||||
cri,
|
||||
SessionsCollection::generateCreateIndexesCmd(),
|
||||
|
|
|
|||
|
|
@ -217,7 +217,6 @@ ShardsvrDropIndexesCommand::Invocation::Response ShardsvrDropIndexesCommand::Inv
|
|||
auto shardResponses =
|
||||
scatterGatherVersionedTargetByRoutingTableNoThrowOnStaleShardVersionErrors(
|
||||
opCtx,
|
||||
resolvedNs.dbName(),
|
||||
resolvedNs,
|
||||
cri,
|
||||
retryState.shardsWithSuccessResponses,
|
||||
|
|
|
|||
|
|
@ -367,6 +367,7 @@ std::vector<AsyncRequestsSender::Request> buildVersionedRequestsForTargetedShard
|
|||
std::vector<AsyncRequestsSender::Response> gatherResponsesImpl(
|
||||
OperationContext* opCtx,
|
||||
const DatabaseName& dbName,
|
||||
const NamespaceString& nss,
|
||||
const ReadPreferenceSetting& readPref,
|
||||
Shard::RetryPolicy retryPolicy,
|
||||
const std::vector<AsyncRequestsSender::Request>& requests,
|
||||
|
|
@ -439,21 +440,32 @@ std::vector<AsyncRequestsSender::Response> gatherResponsesImpl(
|
|||
std::vector<AsyncRequestsSender::Response> gatherResponses(
|
||||
OperationContext* opCtx,
|
||||
const DatabaseName& dbName,
|
||||
const NamespaceString& nss,
|
||||
const ReadPreferenceSetting& readPref,
|
||||
Shard::RetryPolicy retryPolicy,
|
||||
const std::vector<AsyncRequestsSender::Request>& requests) {
|
||||
return gatherResponsesImpl(
|
||||
opCtx, dbName, readPref, retryPolicy, requests, true /* throwOnStaleShardVersionErrors */);
|
||||
return gatherResponsesImpl(opCtx,
|
||||
dbName,
|
||||
nss,
|
||||
readPref,
|
||||
retryPolicy,
|
||||
requests,
|
||||
true /* throwOnStaleShardVersionErrors */);
|
||||
}
|
||||
|
||||
std::vector<AsyncRequestsSender::Response> gatherResponsesNoThrowOnStaleShardVersionErrors(
|
||||
OperationContext* opCtx,
|
||||
const DatabaseName& dbName,
|
||||
const NamespaceString& nss,
|
||||
const ReadPreferenceSetting& readPref,
|
||||
Shard::RetryPolicy retryPolicy,
|
||||
const std::vector<AsyncRequestsSender::Request>& requests) {
|
||||
return gatherResponsesImpl(
|
||||
opCtx, dbName, readPref, retryPolicy, requests, false /* throwOnStaleShardVersionErrors */);
|
||||
return gatherResponsesImpl(opCtx,
|
||||
nss.dbName(),
|
||||
nss,
|
||||
readPref,
|
||||
retryPolicy,
|
||||
requests,
|
||||
false /* throwOnStaleShardVersionErrors */);
|
||||
}
|
||||
|
||||
BSONObj appendDbVersionIfPresent(BSONObj cmdObj, const CachedDatabaseInfo& dbInfo) {
|
||||
|
|
@ -571,7 +583,7 @@ std::vector<AsyncRequestsSender::Response> scatterGatherUnversionedTargetAllShar
|
|||
requests.emplace_back(std::move(shardId), cmdObj);
|
||||
}
|
||||
|
||||
return gatherResponses(opCtx, dbName, readPref, retryPolicy, requests);
|
||||
return gatherResponses(opCtx, dbName, NamespaceString(dbName), readPref, retryPolicy, requests);
|
||||
}
|
||||
|
||||
std::vector<AsyncRequestsSender::Response> scatterGatherUnversionedTargetConfigServerAndShards(
|
||||
|
|
@ -589,12 +601,11 @@ std::vector<AsyncRequestsSender::Response> scatterGatherUnversionedTargetConfigS
|
|||
for (auto&& shardId : shardIds)
|
||||
requests.emplace_back(std::move(shardId), cmdObj);
|
||||
|
||||
return gatherResponses(opCtx, dbName, readPref, retryPolicy, requests);
|
||||
return gatherResponses(opCtx, dbName, NamespaceString(dbName), readPref, retryPolicy, requests);
|
||||
}
|
||||
|
||||
std::vector<AsyncRequestsSender::Response> scatterGatherVersionedTargetByRoutingTable(
|
||||
OperationContext* opCtx,
|
||||
const DatabaseName& dbName,
|
||||
const NamespaceString& nss,
|
||||
const CollectionRoutingInfo& cri,
|
||||
const BSONObj& cmdObj,
|
||||
|
|
@ -612,21 +623,12 @@ std::vector<AsyncRequestsSender::Response> scatterGatherVersionedTargetByRouting
|
|||
boost::none /*explainVerbosity*/,
|
||||
letParameters,
|
||||
runtimeConstants);
|
||||
return scatterGatherVersionedTargetByRoutingTable(expCtx,
|
||||
dbName,
|
||||
nss,
|
||||
cri,
|
||||
cmdObj,
|
||||
readPref,
|
||||
retryPolicy,
|
||||
query,
|
||||
collation,
|
||||
eligibleForSampling);
|
||||
return scatterGatherVersionedTargetByRoutingTable(
|
||||
expCtx, nss, cri, cmdObj, readPref, retryPolicy, query, collation, eligibleForSampling);
|
||||
}
|
||||
|
||||
[[nodiscard]] std::vector<AsyncRequestsSender::Response> scatterGatherVersionedTargetByRoutingTable(
|
||||
boost::intrusive_ptr<ExpressionContext> expCtx,
|
||||
const DatabaseName& dbName,
|
||||
const NamespaceString& nss,
|
||||
const CollectionRoutingInfo& cri,
|
||||
const BSONObj& cmdObj,
|
||||
|
|
@ -637,13 +639,13 @@ std::vector<AsyncRequestsSender::Response> scatterGatherVersionedTargetByRouting
|
|||
bool eligibleForSampling) {
|
||||
const auto requests = buildVersionedRequestsForTargetedShards(
|
||||
expCtx, nss, cri, {} /* shardsToSkip */, cmdObj, query, collation, eligibleForSampling);
|
||||
return gatherResponses(expCtx->getOperationContext(), dbName, readPref, retryPolicy, requests);
|
||||
return gatherResponses(
|
||||
expCtx->getOperationContext(), nss.dbName(), nss, readPref, retryPolicy, requests);
|
||||
}
|
||||
|
||||
std::vector<AsyncRequestsSender::Response>
|
||||
scatterGatherVersionedTargetByRoutingTableNoThrowOnStaleShardVersionErrors(
|
||||
OperationContext* opCtx,
|
||||
const DatabaseName& dbName,
|
||||
const NamespaceString& nss,
|
||||
const CollectionRoutingInfo& cri,
|
||||
const std::set<ShardId>& shardsToSkip,
|
||||
|
|
@ -665,7 +667,7 @@ scatterGatherVersionedTargetByRoutingTableNoThrowOnStaleShardVersionErrors(
|
|||
expCtx, nss, cri, shardsToSkip, cmdObj, query, collation);
|
||||
|
||||
return gatherResponsesNoThrowOnStaleShardVersionErrors(
|
||||
opCtx, dbName, readPref, retryPolicy, requests);
|
||||
opCtx, nss, readPref, retryPolicy, requests);
|
||||
}
|
||||
|
||||
AsyncRequestsSender::Response executeCommandAgainstDatabasePrimaryOnlyAttachingDbVersion(
|
||||
|
|
@ -681,6 +683,7 @@ AsyncRequestsSender::Response executeCommandAgainstDatabasePrimaryOnlyAttachingD
|
|||
auto responses =
|
||||
gatherResponses(opCtx,
|
||||
dbName,
|
||||
NamespaceString(dbName),
|
||||
readPref,
|
||||
retryPolicy,
|
||||
std::vector<AsyncRequestsSender::Request>{AsyncRequestsSender::Request(
|
||||
|
|
@ -710,6 +713,7 @@ AsyncRequestsSender::Response executeCommandAgainstShardWithMinKeyChunk(
|
|||
auto responses = gatherResponses(
|
||||
opCtx,
|
||||
nss.dbName(),
|
||||
nss,
|
||||
readPref,
|
||||
retryPolicy,
|
||||
buildVersionedRequestsForTargetedShards(
|
||||
|
|
|
|||
|
|
@ -153,6 +153,7 @@ std::vector<AsyncRequestsSender::Request> buildVersionedRequests(
|
|||
std::vector<AsyncRequestsSender::Response> gatherResponses(
|
||||
OperationContext* opCtx,
|
||||
const DatabaseName& dbName,
|
||||
const NamespaceString& nss,
|
||||
const ReadPreferenceSetting& readPref,
|
||||
Shard::RetryPolicy retryPolicy,
|
||||
const std::vector<AsyncRequestsSender::Request>& requests);
|
||||
|
|
@ -163,7 +164,7 @@ std::vector<AsyncRequestsSender::Response> gatherResponses(
|
|||
*/
|
||||
std::vector<AsyncRequestsSender::Response> gatherResponsesNoThrowOnStaleShardVersionErrors(
|
||||
OperationContext* opCtx,
|
||||
StringData dbName,
|
||||
const NamespaceString& nss,
|
||||
const ReadPreferenceSetting& readPref,
|
||||
Shard::RetryPolicy retryPolicy,
|
||||
const std::vector<AsyncRequestsSender::Request>& requests);
|
||||
|
|
@ -307,7 +308,6 @@ std::vector<AsyncRequestsSender::Response> scatterGatherUnversionedTargetConfigS
|
|||
*/
|
||||
[[nodiscard]] std::vector<AsyncRequestsSender::Response> scatterGatherVersionedTargetByRoutingTable(
|
||||
OperationContext* opCtx,
|
||||
const DatabaseName& dbName,
|
||||
const NamespaceString& nss,
|
||||
const CollectionRoutingInfo& cri,
|
||||
const BSONObj& cmdObj,
|
||||
|
|
@ -325,7 +325,6 @@ std::vector<AsyncRequestsSender::Response> scatterGatherUnversionedTargetConfigS
|
|||
*/
|
||||
[[nodiscard]] std::vector<AsyncRequestsSender::Response> scatterGatherVersionedTargetByRoutingTable(
|
||||
boost::intrusive_ptr<ExpressionContext> expCtx,
|
||||
const DatabaseName& dbName,
|
||||
const NamespaceString& nss,
|
||||
const CollectionRoutingInfo& cri,
|
||||
const BSONObj& cmdObj,
|
||||
|
|
@ -346,7 +345,6 @@ std::vector<AsyncRequestsSender::Response> scatterGatherUnversionedTargetConfigS
|
|||
std::vector<AsyncRequestsSender::Response>
|
||||
scatterGatherVersionedTargetByRoutingTableNoThrowOnStaleShardVersionErrors(
|
||||
OperationContext* opCtx,
|
||||
const DatabaseName& dbName,
|
||||
const NamespaceString& nss,
|
||||
const CollectionRoutingInfo& cri,
|
||||
const std::set<ShardId>& shardsToSkip,
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ std::vector<AsyncRequestsSender::Request> buildUnshardedRequestsForAllShards(
|
|||
// TODO (SERVER-100309): remove once 9.0 becomes last LTS.
|
||||
AsyncRequestsSender::Response executeCommandAgainstFirstShard(OperationContext* opCtx,
|
||||
const DatabaseName& dbName,
|
||||
const NamespaceString& nss,
|
||||
const CachedDatabaseInfo& dbInfo,
|
||||
const BSONObj& cmdObj,
|
||||
const ReadPreferenceSetting& readPref,
|
||||
|
|
@ -101,6 +102,7 @@ AsyncRequestsSender::Response executeCommandAgainstFirstShard(OperationContext*
|
|||
auto responses =
|
||||
gatherResponses(opCtx,
|
||||
dbName,
|
||||
nss,
|
||||
readPref,
|
||||
retryPolicy,
|
||||
buildUnshardedRequestsForAllShards(
|
||||
|
|
@ -266,6 +268,7 @@ CreateCollectionResponse createCollection(OperationContext* opCtx,
|
|||
return executeCommandAgainstFirstShard(
|
||||
opCtx,
|
||||
nss.dbName(),
|
||||
nss,
|
||||
dbInfo,
|
||||
cmdObjWithWc,
|
||||
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
|
||||
|
|
|
|||
|
|
@ -152,6 +152,7 @@ public:
|
|||
try {
|
||||
auto response = gatherResponses(opCtx,
|
||||
DatabaseName::kAdmin,
|
||||
nss,
|
||||
std::move(readPref),
|
||||
Shard::RetryPolicy::kIdempotent,
|
||||
requests)
|
||||
|
|
|
|||
|
|
@ -79,8 +79,7 @@ public:
|
|||
// constraint is not respected we will get a InvalidOptions as part of the response.
|
||||
auto response =
|
||||
scatterGatherVersionedTargetByRoutingTable(opCtx,
|
||||
nss.dbName(),
|
||||
ns(),
|
||||
nss,
|
||||
cri,
|
||||
filteredCmdObj,
|
||||
ReadPreferenceSetting::get(opCtx),
|
||||
|
|
|
|||
|
|
@ -279,7 +279,6 @@ public:
|
|||
// statistics.
|
||||
auto unscaledShardResults = scatterGatherVersionedTargetByRoutingTable(
|
||||
opCtx,
|
||||
nss.dbName(),
|
||||
targeter.getNS(),
|
||||
cri,
|
||||
applyReadWriteConcern(
|
||||
|
|
|
|||
|
|
@ -145,7 +145,6 @@ public:
|
|||
|
||||
auto shardResponses = scatterGatherVersionedTargetByRoutingTable(
|
||||
opCtx,
|
||||
nss.dbName(),
|
||||
targeter.getNS(),
|
||||
routingInfo,
|
||||
CommandHelpers::filterCommandRequestForPassthrough(
|
||||
|
|
|
|||
|
|
@ -132,7 +132,6 @@ public:
|
|||
const auto callShardFn = [&](const BSONObj& cmdObj, const BSONObj& routingQuery) {
|
||||
auto shardResults =
|
||||
scatterGatherVersionedTargetByRoutingTable(opCtx,
|
||||
nss.dbName(),
|
||||
nss,
|
||||
cri,
|
||||
cmdObj,
|
||||
|
|
|
|||
|
|
@ -137,7 +137,6 @@ public:
|
|||
}();
|
||||
auto response =
|
||||
scatterGatherVersionedTargetByRoutingTable(opCtx,
|
||||
nss.dbName(),
|
||||
nss,
|
||||
cri,
|
||||
filteredCmdObj,
|
||||
|
|
|
|||
|
|
@ -109,7 +109,6 @@ public:
|
|||
uassertStatusOK(Grid::get(opCtx)->catalogCache()->getCollectionRoutingInfo(opCtx, nss));
|
||||
auto results = scatterGatherVersionedTargetByRoutingTable(
|
||||
opCtx,
|
||||
nss.dbName(),
|
||||
nss,
|
||||
cri,
|
||||
applyReadWriteConcern(
|
||||
|
|
|
|||
|
|
@ -128,7 +128,6 @@ public:
|
|||
uassertStatusOK(Grid::get(opCtx)->catalogCache()->getCollectionRoutingInfo(opCtx, nss));
|
||||
auto shardResponses = scatterGatherVersionedTargetByRoutingTable(
|
||||
opCtx,
|
||||
nss.dbName(),
|
||||
nss,
|
||||
cri,
|
||||
applyReadWriteConcern(
|
||||
|
|
|
|||
|
|
@ -103,7 +103,6 @@ public:
|
|||
setReadWriteConcern(opCtx, cmd, this);
|
||||
auto shardResponses = scatterGatherVersionedTargetByRoutingTable(
|
||||
opCtx,
|
||||
nss.dbName(),
|
||||
nss,
|
||||
cri,
|
||||
CommandHelpers::filterCommandRequestForPassthrough(cmd.toBSON()),
|
||||
|
|
|
|||
|
|
@ -262,7 +262,6 @@ public:
|
|||
|
||||
shardResponses = scatterGatherVersionedTargetByRoutingTable(
|
||||
expCtx,
|
||||
dbName,
|
||||
nss,
|
||||
cri,
|
||||
applyReadWriteConcern(
|
||||
|
|
@ -430,7 +429,6 @@ public:
|
|||
try {
|
||||
shardResponses =
|
||||
scatterGatherVersionedTargetByRoutingTable(opCtx,
|
||||
nss.dbName(),
|
||||
nss,
|
||||
cri,
|
||||
explainCmd,
|
||||
|
|
|
|||
|
|
@ -311,7 +311,6 @@ public:
|
|||
try {
|
||||
shardResponses = scatterGatherVersionedTargetByRoutingTable(
|
||||
opCtx,
|
||||
nss.dbName(),
|
||||
nss,
|
||||
cri,
|
||||
ClusterExplain::wrapAsExplain(
|
||||
|
|
@ -408,7 +407,6 @@ public:
|
|||
try {
|
||||
shardResponses = scatterGatherVersionedTargetByRoutingTable(
|
||||
opCtx,
|
||||
nss.dbName(),
|
||||
nss,
|
||||
cri,
|
||||
applyReadWriteConcern(opCtx, this, distinctReadyForPassthrough),
|
||||
|
|
|
|||
|
|
@ -292,7 +292,6 @@ public:
|
|||
|
||||
shardResponses = scatterGatherVersionedTargetByRoutingTable(
|
||||
opCtx,
|
||||
_cmdRequest->getNamespaceOrUUID().nss().dbName(),
|
||||
_cmdRequest->getNamespaceOrUUID().nss(),
|
||||
cri,
|
||||
explainCmd,
|
||||
|
|
|
|||
|
|
@ -123,7 +123,6 @@ public:
|
|||
uassertStatusOK(Grid::get(opCtx)->catalogCache()->getCollectionRoutingInfo(opCtx, nss));
|
||||
auto shardResponses = scatterGatherVersionedTargetByRoutingTable(
|
||||
opCtx,
|
||||
nss.dbName(),
|
||||
nss,
|
||||
cri,
|
||||
applyReadWriteConcern(
|
||||
|
|
|
|||
|
|
@ -125,7 +125,6 @@ bool ClusterPlanCacheClearCmd::run(OperationContext* opCtx,
|
|||
uassertStatusOK(Grid::get(opCtx)->catalogCache()->getCollectionRoutingInfo(opCtx, nss));
|
||||
auto shardResponses = scatterGatherVersionedTargetByRoutingTable(
|
||||
opCtx,
|
||||
nss.dbName(),
|
||||
nss,
|
||||
cri,
|
||||
applyReadWriteConcern(
|
||||
|
|
|
|||
|
|
@ -104,7 +104,6 @@ public:
|
|||
setReadWriteConcern(opCtx, cmd, this);
|
||||
auto shardResults = scatterGatherVersionedTargetByRoutingTable(
|
||||
opCtx,
|
||||
nss.dbName(),
|
||||
nss,
|
||||
cri,
|
||||
CommandHelpers::filterCommandRequestForPassthrough(cmd.toBSON()),
|
||||
|
|
|
|||
|
|
@ -1056,6 +1056,7 @@ void TransactionRouter::Router::_clearPendingParticipants(OperationContext* opCt
|
|||
}
|
||||
auto responses = gatherResponses(opCtx,
|
||||
DatabaseName::kAdmin,
|
||||
NamespaceString(DatabaseName::kAdmin),
|
||||
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
|
||||
Shard::RetryPolicy::kIdempotent,
|
||||
abortRequests);
|
||||
|
|
@ -1738,6 +1739,7 @@ BSONObj TransactionRouter::Router::abortTransaction(OperationContext* opCtx) {
|
|||
|
||||
const auto responses = gatherResponses(opCtx,
|
||||
DatabaseName::kAdmin,
|
||||
NamespaceString(DatabaseName::kAdmin),
|
||||
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
|
||||
Shard::RetryPolicy::kIdempotent,
|
||||
abortRequests);
|
||||
|
|
@ -1841,6 +1843,7 @@ void TransactionRouter::Router::implicitlyAbortTransaction(OperationContext* opC
|
|||
// Ignore the responses.
|
||||
gatherResponses(opCtx,
|
||||
DatabaseName::kAdmin,
|
||||
NamespaceString(DatabaseName::kAdmin),
|
||||
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
|
||||
Shard::RetryPolicy::kIdempotent,
|
||||
abortRequests);
|
||||
|
|
|
|||
Loading…
Reference in New Issue