SERVER-109797 Rename command running functions in Shard (#40525)

Co-authored-by: Blake Oler <blake.oler@mongodb.com>
GitOrigin-RevId: 6d96de70d2623944cbb567cdaf12f5800ad47ddf
This commit is contained in:
Guillaume Racicot 2025-09-02 10:15:48 -04:00 committed by MongoDB Bot
parent 9e35b92e50
commit b739801eea
81 changed files with 621 additions and 637 deletions

View File

@ -72,11 +72,12 @@ StatusWith<std::set<boost::optional<TenantId>>> getTenantsWithConfigDbsOnShard(
listDbCommand.setNameOnly(true);
std::set<boost::optional<TenantId>> tenantIds;
auto swListDbResponse = shard.runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
listDbCommand.toBSON(),
Shard::RetryPolicy::kIdempotent);
auto swListDbResponse =
shard.runCommandWithIndefiniteRetries(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
listDbCommand.toBSON(),
Shard::RetryPolicy::kIdempotent);
if (!swListDbResponse.isOK()) {
return swListDbResponse.getStatus();
}

View File

@ -136,12 +136,12 @@ getFCVAndClusterParametersFromConfigServer() {
findFCV.setReadConcern(repl::ReadConcernArgs::kSnapshot);
findFCV.setLimit(1);
auto findFCVResponseBSON =
uassertStatusOK(
configServers->runCommand(opCtx.get(),
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
findFCV.getDbName(),
findFCV.toBSON(),
Shard::RetryPolicy::kIdempotent))
uassertStatusOK(configServers->runCommandWithIndefiniteRetries(
opCtx.get(),
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
findFCV.getDbName(),
findFCV.toBSON(),
Shard::RetryPolicy::kIdempotent))
.response;
auto findFCVResponse =
uassertStatusOK(CursorResponse::parseFromBSON(findFCVResponseBSON));

View File

@ -51,12 +51,12 @@ void setClusterParameterImplRouter(OperationContext* opCtx,
const auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
const auto cmdResponse = uassertStatusOK(configShard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
configsvrSetClusterParameter.toBSON(),
Shard::RetryPolicy::kIdempotent));
const auto cmdResponse =
uassertStatusOK(configShard->runCommand(opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
configsvrSetClusterParameter.toBSON(),
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(Shard::CommandResponse::getEffectiveStatus(std::move(cmdResponse)));
}

View File

@ -337,12 +337,11 @@ void handleDropPendingDBsGarbage(OperationContext* parentOpCtx) {
request.setDbName(DatabaseName::kAdmin);
request.setTypes({{DDLCoordinatorType_serializer(DDLCoordinatorTypeEnum::kDropDatabase)}});
const auto response = shard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
request.toBSON(),
Shard::RetryPolicy::kIdempotent);
const auto response = shard->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
request.toBSON(),
Shard::RetryPolicy::kIdempotent);
uassertStatusOK(Shard::CommandResponse::getEffectiveStatus(response));
}

View File

@ -212,7 +212,7 @@ QuerySettingsStage::createQueryShapeRepresentativeQueriesCursor(OperationContext
findRepresentativeQueriesCmd.setReadConcern(readConcernArgs);
auto configShard = grid->shardRegistry()->getConfigShard();
auto shardResponse = uassertStatusOK(configShard->runCommandWithFixedRetryAttempts(
auto shardResponse = uassertStatusOK(configShard->runCommand(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
nss.dbName(),

View File

@ -400,7 +400,7 @@ void forcePrimaryDatabaseRefreshAndWaitForReplication(OperationContext* opCtx,
// currently have no way to detect a topology change/rollback after the return from primary is
// received.
runAndThrowIfTermChanged(opCtx, [&](auto term) {
auto cmdResponse = uassertStatusOK(selfShard->runCommandWithFixedRetryAttempts(
auto cmdResponse = uassertStatusOK(selfShard->runCommand(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
@ -1381,7 +1381,7 @@ ShardServerCatalogCacheLoaderImpl::_forcePrimaryCollectionRefreshAndWaitForRepli
return runAndThrowIfTermChanged(opCtx, [&](auto term) {
auto notif = _namespaceNotifications.createNotification(nss);
auto cmdResponse = uassertStatusOK(selfShard->runCommandWithFixedRetryAttempts(
auto cmdResponse = uassertStatusOK(selfShard->runCommand(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,

View File

@ -71,12 +71,12 @@ public:
&opCtx->getWriteConcern());
auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
auto cmdResponse = uassertStatusOK(configShard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
configsvrAbortReshardCollection.toBSON(),
Shard::RetryPolicy::kIdempotent));
auto cmdResponse = uassertStatusOK(
configShard->runCommand(opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
configsvrAbortReshardCollection.toBSON(),
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(cmdResponse.commandStatus);
uassertStatusOK(cmdResponse.writeConcernStatus);
}

View File

@ -71,12 +71,12 @@ public:
&opCtx->getWriteConcern());
auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
auto cmdResponse = uassertStatusOK(configShard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
configsvrAbortReshardCollection.toBSON(),
Shard::RetryPolicy::kIdempotent));
auto cmdResponse = uassertStatusOK(
configShard->runCommand(opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
configsvrAbortReshardCollection.toBSON(),
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(cmdResponse.commandStatus);
uassertStatusOK(cmdResponse.writeConcernStatus);
}

View File

@ -86,12 +86,12 @@ public:
cmd.serialize(&cmdBuilder);
auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
auto cmdResponseStatus = uassertStatusOK(
configShard->runCommandWithFixedRetryAttempts(opCtx,
kPrimaryOnlyReadPreference,
DatabaseName::kAdmin,
cmdBuilder.obj(),
Shard::RetryPolicy::kIdempotent));
auto cmdResponseStatus =
uassertStatusOK(configShard->runCommand(opCtx,
kPrimaryOnlyReadPreference,
DatabaseName::kAdmin,
cmdBuilder.obj(),
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(cmdResponseStatus.commandStatus);
}

View File

@ -70,12 +70,12 @@ public:
generic_argument_util::setMajorityWriteConcern(cmd, &opCtx->getWriteConcern());
auto cfg = Grid::get(opCtx)->shardRegistry()->getConfigShard();
auto response = uassertStatusOK(cfg->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
cmd.toBSON(),
Shard::RetryPolicy::kIdempotent));
auto response =
uassertStatusOK(cfg->runCommand(opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
cmd.toBSON(),
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(response.commandStatus);
uassertStatusOK(response.writeConcernStatus);
}

View File

@ -139,12 +139,12 @@ CachedDatabaseInfo createDatabase(OperationContext* opCtx,
auto txnRouterResourceYielder = TransactionRouterResourceYielder::makeForRemoteCommand();
auto sendCommand = [&] {
auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
auto response = uassertStatusOK(configShard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
request.toBSON(),
Shard::RetryPolicy::kIdempotent));
auto response = uassertStatusOK(
configShard->runCommand(opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
request.toBSON(),
Shard::RetryPolicy::kIdempotent));
return response;
};
auto response = runWithYielding(opCtx, txnRouterResourceYielder.get(), sendCommand);

View File

@ -101,12 +101,12 @@ public:
generic_argument_util::setMajorityWriteConcern(configsvrCreateDatabase);
auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
auto response = uassertStatusOK(configShard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
configsvrCreateDatabase.toBSON(),
Shard::RetryPolicy::kIdempotent));
auto response = uassertStatusOK(
configShard->runCommand(opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
configsvrCreateDatabase.toBSON(),
Shard::RetryPolicy::kIdempotent));
uassertStatusOKWithContext(response.commandStatus,
str::stream() << "Database " << dbName.toStringForErrorMsg()

View File

@ -147,12 +147,11 @@ public:
}
const auto s = std::move(shardStatus.getValue());
auto response = uassertStatusOK(
s->runCommandWithFixedRetryAttempts(opCtx,
ReadPreferenceSetting::get(opCtx),
DatabaseName::kAdmin,
filteredCmd,
Shard::RetryPolicy::kIdempotent));
auto response = uassertStatusOK(s->runCommand(opCtx,
ReadPreferenceSetting::get(opCtx),
DatabaseName::kAdmin,
filteredCmd,
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(response.commandStatus);
BSONObj x = std::move(response.response);

View File

@ -97,12 +97,12 @@ public:
shardSvrMergeAllChunksOnShard.setMaxTimeProcessingChunksMS(
req.getMaxTimeProcessingChunksMS());
auto swCommandResponse = shard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
shardSvrMergeAllChunksOnShard.toBSON(),
Shard::RetryPolicy::kIdempotent);
auto swCommandResponse =
shard->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
shardSvrMergeAllChunksOnShard.toBSON(),
Shard::RetryPolicy::kIdempotent);
uassertStatusOK(Shard::CommandResponse::getEffectiveStatus(swCommandResponse));

View File

@ -115,12 +115,12 @@ public:
auto shard = uassertStatusOK(
Grid::get(opCtx)->shardRegistry()->getShard(opCtx, firstChunk.getShardId()));
auto response = uassertStatusOK(shard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
cmdBuilder.obj(),
Shard::RetryPolicy::kNotIdempotent));
auto response = uassertStatusOK(
shard->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
cmdBuilder.obj(),
Shard::RetryPolicy::kNotIdempotent));
uassertStatusOK(response.commandStatus);
Grid::get(opCtx)->catalogCache()->onStaleCollectionVersion(ns(), boost::none);

View File

@ -123,7 +123,7 @@ public:
parsedRequest.appendAsConfigCommand(&cmdBuilder);
auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
auto cmdResponseStatus = uassertStatusOK(configShard->runCommandWithFixedRetryAttempts(
auto cmdResponseStatus = uassertStatusOK(configShard->runCommand(
opCtx,
kPrimaryOnlyReadPreference,
DatabaseName::kAdmin,

View File

@ -75,13 +75,13 @@ public:
cmd.serialize(&cmdBuilder);
auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
auto cmdResponse = uassertStatusOK(configShard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
CommandHelpers::appendMajorityWriteConcern(cmdBuilder.obj(),
opCtx->getWriteConcern()),
Shard::RetryPolicy::kIdempotent));
auto cmdResponse = uassertStatusOK(
configShard->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
CommandHelpers::appendMajorityWriteConcern(
cmdBuilder.obj(), opCtx->getWriteConcern()),
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(cmdResponse.commandStatus);
}

View File

@ -89,12 +89,13 @@ public:
configsvrRequest.setWriteConcern(defaultMajorityWriteConcernDoNotUse());
auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
const auto commandResponse = uassertStatusOK(
configShard->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
configsvrRequest.toBSON(),
Shard::RetryPolicy::kIdempotent));
const auto commandResponse =
uassertStatusOK(configShard->runCommandWithIndefiniteRetries(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
configsvrRequest.toBSON(),
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(Shard::CommandResponse::getEffectiveStatus(commandResponse));
}

View File

@ -382,11 +382,12 @@ ExecutorFuture<void> CollModCoordinator::_runImpl(
const auto& configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
uassertStatusOK(Shard::CommandResponse::getEffectiveStatus(
configShard->runCommand(opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
nss().dbName(),
request.toBSON(),
Shard::RetryPolicy::kIdempotent)));
configShard->runCommandWithIndefiniteRetries(
opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
nss().dbName(),
request.toBSON(),
Shard::RetryPolicy::kIdempotent)));
}
}))
.then(_buildPhaseHandler(

View File

@ -183,12 +183,12 @@ void refreshDbVersionOnPrimaryShard(OperationContext* opCtx,
const ShardId& primaryShard) {
const auto shardRegistry = Grid::get(opCtx)->shardRegistry();
const auto primaryShardPtr = uassertStatusOK(shardRegistry->getShard(opCtx, primaryShard));
auto cmdResponse = uassertStatusOK(primaryShardPtr->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
BSON("_flushDatabaseCacheUpdates" << dbNameStr),
Shard::RetryPolicy::kIdempotent));
auto cmdResponse = uassertStatusOK(
primaryShardPtr->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
BSON("_flushDatabaseCacheUpdates" << dbNameStr),
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(cmdResponse.commandStatus);
}

View File

@ -599,12 +599,12 @@ std::vector<NamespaceString> MovePrimaryCoordinator::cloneDataToRecipient(Operat
};
auto clonedCollections = [&](const BSONObj& command) {
const auto cloneResponse =
toShard->runCommand(opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
command,
Shard::RetryPolicy::kNoRetry);
const auto cloneResponse = toShard->runCommandWithIndefiniteRetries(
opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
command,
Shard::RetryPolicy::kNoRetry);
uassertStatusOKWithContext(
Shard::CommandResponse::getEffectiveStatus(cloneResponse),
@ -654,11 +654,11 @@ void MovePrimaryCoordinator::commitMetadataToConfig(
const auto config = Grid::get(opCtx)->shardRegistry()->getConfigShard();
const auto commitResponse =
config->runCommandWithFixedRetryAttempts(opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
commitCommand,
Shard::RetryPolicy::kIdempotent);
config->runCommand(opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
commitCommand,
Shard::RetryPolicy::kIdempotent);
uassertStatusOKWithContext(
Shard::CommandResponse::getEffectiveStatus(commitResponse),
@ -905,12 +905,11 @@ void MovePrimaryCoordinator::enterCriticalSectionOnRecipient(
const auto shardRegistry = Grid::get(opCtx)->shardRegistry();
const auto toShard = uassertStatusOK(shardRegistry->getShard(opCtx, toShardId));
return toShard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
enterCriticalSectionCommand,
Shard::RetryPolicy::kIdempotent);
return toShard->runCommand(opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
enterCriticalSectionCommand,
Shard::RetryPolicy::kIdempotent);
}();
uassertStatusOKWithContext(
@ -958,12 +957,11 @@ void MovePrimaryCoordinator::exitCriticalSectionOnRecipient(
const auto shardRegistry = Grid::get(opCtx)->shardRegistry();
const auto toShard = uassertStatusOK(shardRegistry->getShard(opCtx, toShardId));
return toShard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
exitCriticalSectionCommand,
Shard::RetryPolicy::kIdempotent);
return toShard->runCommand(opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
exitCriticalSectionCommand,
Shard::RetryPolicy::kIdempotent);
}();
uassertStatusOKWithContext(

View File

@ -342,15 +342,13 @@ ExecutorFuture<void> RefineCollectionShardKeyCoordinator::_runImpl(
commitRequest.setCommitRefineCollectionShardKeyRequest(cRCSreq);
generic_argument_util::setMajorityWriteConcern(commitRequest);
auto commitResponse = Grid::get(opCtx)
->shardRegistry()
->getConfigShard()
->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
commitRequest.toBSON(),
Shard::RetryPolicy::kIdempotent);
auto commitResponse =
Grid::get(opCtx)->shardRegistry()->getConfigShard()->runCommand(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
commitRequest.toBSON(),
Shard::RetryPolicy::kIdempotent);
uassertStatusOK(Shard::CommandResponse::getEffectiveStatus(commitResponse));

View File

@ -333,12 +333,12 @@ std::vector<ShardId> getCurrentCollPlacement(OperationContext* opCtx, const UUID
distinctRequest.setReadConcern(repl::ReadConcernArgs::kLocal);
auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
auto reply = uassertStatusOK(configShard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly, TagSet{}),
DatabaseName::kConfig,
distinctRequest.toBSON(),
Shard::RetryPolicy::kIdempotent));
auto reply = uassertStatusOK(
configShard->runCommand(opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly, TagSet{}),
DatabaseName::kConfig,
distinctRequest.toBSON(),
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(Shard::CommandResponse::getEffectiveStatus(reply));
std::vector<ShardId> shardIds;

View File

@ -241,12 +241,12 @@ ExecutorFuture<void> ReshardCollectionCoordinator::_runImpl(
const auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
const auto cmdResponse = uassertStatusOK(configShard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
configsvrReshardCollection.toBSON(),
Shard::RetryPolicy::kIdempotent));
const auto cmdResponse = uassertStatusOK(
configShard->runCommand(opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
configsvrReshardCollection.toBSON(),
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(Shard::CommandResponse::getEffectiveStatus(cmdResponse));
}));
}

View File

@ -403,14 +403,15 @@ std::vector<BSONObj> ValidationBehaviorsShardCollection::loadIndexes(
void ValidationBehaviorsShardCollection::verifyUsefulNonMultiKeyIndex(
const NamespaceString& nss, const BSONObj& proposedKey) const {
uassertStatusOK(Shard::CommandResponse::getEffectiveStatus(_dataShard->runCommand(
_opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
BSON(kCheckShardingIndexCmdName
<< NamespaceStringUtil::serialize(nss, SerializationContext::stateDefault())
<< kKeyPatternField << proposedKey),
Shard::RetryPolicy::kIdempotent)));
uassertStatusOK(
Shard::CommandResponse::getEffectiveStatus(_dataShard->runCommandWithIndefiniteRetries(
_opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
BSON(kCheckShardingIndexCmdName
<< NamespaceStringUtil::serialize(nss, SerializationContext::stateDefault())
<< kKeyPatternField << proposedKey),
Shard::RetryPolicy::kIdempotent)));
}
void ValidationBehaviorsShardCollection::verifyCanCreateShardKeyIndex(const NamespaceString& nss,
@ -532,16 +533,17 @@ void ValidationBehaviorsReshardingBulkIndex::verifyUsefulNonMultiKeyIndex(
uassertStatusOK(Grid::get(_opCtx)->catalogCache()->getCollectionRoutingInfo(_opCtx, nss));
auto shard = uassertStatusOK(Grid::get(_opCtx)->shardRegistry()->getShard(
_opCtx, cri.getChunkManager().getMinKeyShardIdWithSimpleCollation()));
uassertStatusOK(Shard::CommandResponse::getEffectiveStatus(shard->runCommand(
_opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
appendShardVersion(
BSON(kCheckShardingIndexCmdName
<< NamespaceStringUtil::serialize(nss, SerializationContext::stateDefault())
<< kKeyPatternField << proposedKey),
cri.getShardVersion(shard->getId())),
Shard::RetryPolicy::kIdempotent)));
uassertStatusOK(
Shard::CommandResponse::getEffectiveStatus(shard->runCommandWithIndefiniteRetries(
_opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
appendShardVersion(
BSON(kCheckShardingIndexCmdName
<< NamespaceStringUtil::serialize(nss, SerializationContext::stateDefault())
<< kKeyPatternField << proposedKey),
cri.getShardVersion(shard->getId())),
Shard::RetryPolicy::kIdempotent)));
}
void ValidationBehaviorsReshardingBulkIndex::verifyCanCreateShardKeyIndex(

View File

@ -83,13 +83,13 @@ StatusWith<long long> retrieveCollectionShardSize(OperationContext* opCtx,
const auto cmdObj =
BSON("dataSize" << NamespaceStringUtil::serialize(ns, SerializationContext::stateDefault())
<< "estimate" << estimate);
auto statStatus = shardStatus.getValue()->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryPreferred},
ns.dbName(),
cmdObj,
maxTimeMSOverride,
Shard::RetryPolicy::kIdempotent);
auto statStatus =
shardStatus.getValue()->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryPreferred},
ns.dbName(),
cmdObj,
maxTimeMSOverride,
Shard::RetryPolicy::kIdempotent);
auto stat = Shard::CommandResponse::getEffectiveStatus(statStatus);
if (!stat.isOK()) {
@ -125,12 +125,12 @@ StatusWith<std::vector<BSONObj>> selectChunkSplitPoints(OperationContext* opCtx,
nss, shardKeyPattern.toBSON(), chunkRange.getMin(), chunkRange.getMax(), chunkSizeBytes);
req.setLimit(limit);
auto cmdStatus = shardStatus.getValue()->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryPreferred},
nss.dbName(),
req.toBSON(),
Shard::RetryPolicy::kIdempotent);
auto cmdStatus =
shardStatus.getValue()->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryPreferred},
nss.dbName(),
req.toBSON(),
Shard::RetryPolicy::kIdempotent);
auto status = Shard::CommandResponse::getEffectiveStatus(cmdStatus);
if (!status.isOK()) {
@ -202,12 +202,12 @@ Status splitChunkAtMultiplePoints(OperationContext* opCtx,
if (!shardStatus.isOK()) {
status = shardStatus.getStatus();
} else {
auto cmdStatus = shardStatus.getValue()->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
cmdObj,
Shard::RetryPolicy::kNotIdempotent);
auto cmdStatus =
shardStatus.getValue()->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
cmdObj,
Shard::RetryPolicy::kNotIdempotent);
if (!cmdStatus.isOK()) {
status = std::move(cmdStatus.getStatus());
} else {

View File

@ -610,12 +610,11 @@ Status ShardingCatalogManager::setFeatureCompatibilityVersionOnShards(OperationC
continue;
}
auto response = shard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
cmdObj,
Shard::RetryPolicy::kIdempotent);
auto response = shard->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
cmdObj,
Shard::RetryPolicy::kIdempotent);
if (!response.isOK()) {
return response.getStatus();
}
@ -652,12 +651,11 @@ Status ShardingCatalogManager::runCloneAuthoritativeMetadataOnShards(OperationCo
request.setWriteConcern(defaultMajorityWriteConcernDoNotUse());
request.setDbName(DatabaseName::kAdmin);
auto response = shard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
request.toBSON(),
Shard::RetryPolicy::kIdempotent);
auto response = shard->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
request.toBSON(),
Shard::RetryPolicy::kIdempotent);
if (!response.isOK()) {
return response.getStatus();

View File

@ -1896,14 +1896,13 @@ void ShardingCatalogManager::upgradeChunksHistory(OperationContext* opCtx,
for (const auto& shardId : shardsOwningChunks) {
auto shard = uassertStatusOK(shardRegistry->getShard(opCtx, shardId));
uassertStatusOK(
Shard::CommandResponse::getEffectiveStatus(shard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
BSON("_flushRoutingTableCacheUpdates"
<< NamespaceStringUtil::serialize(nss, SerializationContext::stateDefault())),
Shard::RetryPolicy::kIdempotent)));
uassertStatusOK(Shard::CommandResponse::getEffectiveStatus(shard->runCommand(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
BSON("_flushRoutingTableCacheUpdates"
<< NamespaceStringUtil::serialize(nss, SerializationContext::stateDefault())),
Shard::RetryPolicy::kIdempotent)));
}
}

View File

@ -811,7 +811,7 @@ void ShardingCatalogManager::initializePlacementHistory(OperationContext* opCtx)
}()});
deleteOp.setWriteConcern(ShardingCatalogClient::writeConcernLocalHavingUpstreamWaiter());
uassertStatusOK(_localConfigShard->runCommandWithFixedRetryAttempts(
uassertStatusOK(_localConfigShard->runCommand(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
NamespaceString::kConfigsvrPlacementHistoryNamespace.dbName(),
@ -1002,12 +1002,12 @@ void ShardingCatalogManager::cleanUpPlacementHistory(OperationContext* opCtx,
write_ops::DeleteCommandRequest deleteRequest(
NamespaceString::kConfigsvrPlacementHistoryNamespace);
deleteRequest.setDeletes(std::move(deleteStatements));
uassertStatusOK(_localConfigShard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
NamespaceString::kConfigsvrPlacementHistoryNamespace.dbName(),
deleteRequest.toBSON(),
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(
_localConfigShard->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
NamespaceString::kConfigsvrPlacementHistoryNamespace.dbName(),
deleteRequest.toBSON(),
Shard::RetryPolicy::kIdempotent));
LOGV2_DEBUG(7068808, 2, "Cleaning up placement history - done deleting entries");
}

View File

@ -242,7 +242,7 @@ void setAllowMigrations(OperationContext* opCtx,
}
const auto swSetAllowMigrationsResult =
Grid::get(opCtx)->shardRegistry()->getConfigShard()->runCommandWithFixedRetryAttempts(
Grid::get(opCtx)->shardRegistry()->getConfigShard()->runCommand(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
@ -301,12 +301,12 @@ void removeTagsMetadataFromConfig(OperationContext* opCtx,
generic_argument_util::setMajorityWriteConcern(configsvrRemoveTagsCmd);
generic_argument_util::setOperationSessionInfo(configsvrRemoveTagsCmd, osi);
const auto swRemoveTagsResult = configShard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
configsvrRemoveTagsCmd.toBSON(),
Shard::RetryPolicy::kIdempotent);
const auto swRemoveTagsResult =
configShard->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
configsvrRemoveTagsCmd.toBSON(),
Shard::RetryPolicy::kIdempotent);
uassertStatusOKWithContext(Shard::CommandResponse::getEffectiveStatus(swRemoveTagsResult),
str::stream() << "Error removing tags for collection "
@ -331,12 +331,12 @@ void removeQueryAnalyzerMetadata(OperationContext* opCtx,
NamespaceString::kConfigQueryAnalyzersNamespace);
generic_argument_util::setMajorityWriteConcern(deleteCmd);
deleteCmd.setDeletes(std::move(deleteOps));
const auto deleteResult = configShard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kConfig,
deleteCmd.toBSON(),
Shard::RetryPolicy::kIdempotent);
const auto deleteResult =
configShard->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kConfig,
deleteCmd.toBSON(),
Shard::RetryPolicy::kIdempotent);
uassertStatusOKWithContext(Shard::CommandResponse::getEffectiveStatus(deleteResult),
str::stream()
@ -358,12 +358,12 @@ void removeQueryAnalyzerMetadata(OperationContext* opCtx,
<< NamespaceStringUtil::serialize(nss, SerializationContext::stateDefault())));
entry.setMulti(false);
deleteCmd.setDeletes({std::move(entry)});
const auto deleteResult = configShard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kConfig,
deleteCmd.toBSON(),
Shard::RetryPolicy::kIdempotent);
const auto deleteResult =
configShard->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kConfig,
deleteCmd.toBSON(),
Shard::RetryPolicy::kIdempotent);
uassertStatusOKWithContext(Shard::CommandResponse::getEffectiveStatus(deleteResult),
str::stream() << "Failed to remove query analyzer documents");

View File

@ -266,12 +266,11 @@ void invokeCommandOnShardWithIdempotentRetryPolicy(OperationContext* opCtx,
LOGV2_DEBUG(22023, 1, "Sending request to recipient", "commandToSend"_attr = redact(cmd));
auto response = recipientShard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
dbName,
cmd,
Shard::RetryPolicy::kIdempotent);
auto response = recipientShard->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
dbName,
cmd,
Shard::RetryPolicy::kIdempotent);
uassertStatusOK(response.getStatus());
uassertStatusOK(getStatusFromWriteCommandReply(response.getValue().response));

View File

@ -111,12 +111,12 @@ public:
defaultMajorityWriteConcernDoNotUse());
auto config = Grid::get(opCtx)->shardRegistry()->getConfigShard();
auto swCommandResponse = config->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
configSvrCommitMergeAllChunksOnShard.toBSON(),
Shard::RetryPolicy::kIdempotent);
auto swCommandResponse =
config->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
configSvrCommitMergeAllChunksOnShard.toBSON(),
Shard::RetryPolicy::kIdempotent);
uassertStatusOK(Shard::CommandResponse::getEffectiveStatus(swCommandResponse));

View File

@ -127,12 +127,15 @@ public:
request.setWriteConcern(defaultMajorityWriteConcernDoNotUse());
auto cmdResponse =
uassertStatusOK(Grid::get(opCtx)->shardRegistry()->getConfigShard()->runCommand(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
request.toBSON(),
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(Grid::get(opCtx)
->shardRegistry()
->getConfigShard()
->runCommandWithIndefiniteRetries(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
request.toBSON(),
Shard::RetryPolicy::kIdempotent));
auto chunkVersionReceived = [&]() -> boost::optional<ChunkVersion> {
// Old versions might not have the shardVersion field

View File

@ -217,13 +217,12 @@ Status splitChunk(OperationContext* opCtx,
auto configCmdObj = request.toConfigCommandBSON(defaultMajorityWriteConcernDoNotUse().toBSON());
auto cmdResponseStatus =
Grid::get(opCtx)->shardRegistry()->getConfigShard()->runCommandWithFixedRetryAttempts(
opCtx,
kPrimaryOnlyReadPreference,
DatabaseName::kAdmin,
configCmdObj,
Shard::RetryPolicy::kIdempotent);
auto cmdResponseStatus = Grid::get(opCtx)->shardRegistry()->getConfigShard()->runCommand(
opCtx,
kPrimaryOnlyReadPreference,
DatabaseName::kAdmin,
configCmdObj,
Shard::RetryPolicy::kIdempotent);
// If we failed to get any response from the config server at all, despite retries, then we
// should just go ahead and fail the whole operation.

View File

@ -553,13 +553,13 @@ StatusWith<repl::OpTimeWith<DatabaseType>> ShardingCatalogClientImpl::_fetchData
HistoricalPlacement ShardingCatalogClientImpl::_fetchPlacementMetadata(
OperationContext* opCtx, ConfigsvrGetHistoricalPlacement&& request) {
auto remoteResponse = uassertStatusOK(_getConfigShard(opCtx)->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
request.toBSON(),
Milliseconds(defaultConfigCommandTimeoutMS.load()),
Shard::RetryPolicy::kIdempotentOrCursorInvalidated));
auto remoteResponse = uassertStatusOK(
_getConfigShard(opCtx)->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
request.toBSON(),
Milliseconds(defaultConfigCommandTimeoutMS.load()),
Shard::RetryPolicy::kIdempotentOrCursorInvalidated));
uassertStatusOK(remoteResponse.commandStatus);
@ -1197,13 +1197,13 @@ Status ShardingCatalogClientImpl::runUserManagementWriteCommand(OperationContext
cmdToRun = modifiedCmd.obj();
}
auto swResponse = _getConfigShard(opCtx)->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
dbname,
cmdToRun,
Milliseconds(defaultConfigCommandTimeoutMS.load()),
Shard::RetryPolicy::kNotIdempotent);
auto swResponse =
_getConfigShard(opCtx)->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
dbname,
cmdToRun,
Milliseconds(defaultConfigCommandTimeoutMS.load()),
Shard::RetryPolicy::kNotIdempotent);
if (!swResponse.isOK()) {
return swResponse.getStatus();
@ -1233,13 +1233,13 @@ bool ShardingCatalogClientImpl::runUserManagementReadCommand(OperationContext* o
const DatabaseName& dbname,
const BSONObj& cmdObj,
BSONObjBuilder* result) {
auto resultStatus = _getConfigShard(opCtx)->runCommandWithFixedRetryAttempts(
opCtx,
kConfigPrimaryPreferredReadPreference,
dbname,
cmdObj,
Milliseconds(defaultConfigCommandTimeoutMS.load()),
Shard::RetryPolicy::kIdempotent);
auto resultStatus =
_getConfigShard(opCtx)->runCommand(opCtx,
kConfigPrimaryPreferredReadPreference,
dbname,
cmdObj,
Milliseconds(defaultConfigCommandTimeoutMS.load()),
Shard::RetryPolicy::kIdempotent);
if (resultStatus.isOK()) {
CommandHelpers::filterCommandReplyForPassthrough(resultStatus.getValue().response, result);
return resultStatus.getValue().commandStatus.isOK();

View File

@ -214,7 +214,7 @@ void ensureChunkVersionIsGreaterThan(OperationContext* opCtx,
hangInEnsureChunkVersionIsGreaterThanInterruptible.pauseWhileSet(opCtx);
const auto ensureChunkVersionIsGreaterThanResponse =
Grid::get(opCtx)->shardRegistry()->getConfigShard()->runCommandWithFixedRetryAttempts(
Grid::get(opCtx)->shardRegistry()->getConfigShard()->runCommand(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,

View File

@ -263,12 +263,13 @@ void ConfigServerHealthObserver::_runSmokeReadShardsCommand(std::shared_ptr<Chec
findOneShardResponse = Grid::get(ctx->opCtx.get())
->shardRegistry()
->getConfigShard()
->runCommand(ctx->opCtx.get(),
readPref,
NamespaceString::kConfigsvrShardsNamespace.dbName(),
findCmdBuilder.done(),
kServerRequestTimeout,
Shard::RetryPolicy::kNoRetry);
->runCommandWithIndefiniteRetries(
ctx->opCtx.get(),
readPref,
NamespaceString::kConfigsvrShardsNamespace.dbName(),
findCmdBuilder.done(),
kServerRequestTimeout,
Shard::RetryPolicy::kNoRetry);
} catch (const DBException& exc) {
findOneShardResponse = StatusWith<Shard::CommandResponse>(exc.toStatus());
}

View File

@ -1422,8 +1422,8 @@ bool ReplicationCoordinatorExternalStateImpl::isCWWCSetOnConfigShard(
OperationContext* opCtx) const {
GetDefaultRWConcern configsvrRequest;
configsvrRequest.setDbName(DatabaseName::kAdmin);
auto cmdResponse = uassertStatusOK(
Grid::get(opCtx)->shardRegistry()->getConfigShard()->runCommandWithFixedRetryAttempts(
auto cmdResponse =
uassertStatusOK(Grid::get(opCtx)->shardRegistry()->getConfigShard()->runCommand(
opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,

View File

@ -1310,13 +1310,13 @@ bool Balancer::_checkOIDs(OperationContext* opCtx) {
}
const auto s = std::move(shardStatus.getValue());
auto result = uassertStatusOK(
s->runCommandWithFixedRetryAttempts(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
BSON("features" << 1),
Seconds(30),
Shard::RetryPolicy::kIdempotent));
auto result =
uassertStatusOK(s->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
BSON("features" << 1),
Seconds(30),
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(result.commandStatus);
BSONObj f = std::move(result.response);
@ -1331,25 +1331,24 @@ bool Balancer::_checkOIDs(OperationContext* opCtx) {
"firstShardId"_attr = shardId,
"secondShardId"_attr = oids[x]);
result = uassertStatusOK(s->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
BSON("features" << 1 << "oidReset" << 1),
Seconds(30),
Shard::RetryPolicy::kIdempotent));
result = uassertStatusOK(
s->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
BSON("features" << 1 << "oidReset" << 1),
Seconds(30),
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(result.commandStatus);
auto otherShardStatus = shardingContext->shardRegistry()->getShard(opCtx, oids[x]);
if (otherShardStatus.isOK()) {
result = uassertStatusOK(
otherShardStatus.getValue()->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
BSON("features" << 1 << "oidReset" << 1),
Seconds(30),
Shard::RetryPolicy::kIdempotent));
result = uassertStatusOK(otherShardStatus.getValue()->runCommand(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
BSON("features" << 1 << "oidReset" << 1),
Seconds(30),
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(result.commandStatus);
}

View File

@ -270,12 +270,12 @@ public:
request.setWriteConcern(defaultMajorityWriteConcern());
const auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
auto swResponse = configShard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kConfig,
request.toBSON(),
Shard::RetryPolicy::kIdempotent);
auto swResponse =
configShard->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kConfig,
request.toBSON(),
Shard::RetryPolicy::kIdempotent);
uassertStatusOK(Shard::CommandResponse::getEffectiveStatus(swResponse));
return write_ops::FindAndModifyCommandReply::parse(
swResponse.getValue().response, IDLParserContext("configureQueryAnalyzer"));

View File

@ -134,13 +134,14 @@ MigrationBatchFetcher<Inserter>::MigrationBatchFetcher(
template <typename Inserter>
BSONObj MigrationBatchFetcher<Inserter>::_fetchBatch(OperationContext* opCtx) {
auto commandResponse = uassertStatusOKWithContext(
_fromShard->runCommand(opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
_migrateCloneRequest,
Shard::RetryPolicy::kNoRetry),
"_migrateClone failed: ");
auto commandResponse =
uassertStatusOKWithContext(_fromShard->runCommandWithIndefiniteRetries(
opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
_migrateCloneRequest,
Shard::RetryPolicy::kNoRetry),
"_migrateClone failed: ");
uassertStatusOKWithContext(Shard::CommandResponse::getEffectiveStatus(commandResponse),
"_migrateClone failed: ");

View File

@ -1563,11 +1563,12 @@ void MigrationDestinationManager::_migrateDriver(OperationContext* outerOpCtx,
auto fetchBatchFn = [&](OperationContext* opCtx, BSONObj* nextBatch) {
auto commandResponse = uassertStatusOKWithContext(
fromShard->runCommand(opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
xferModsRequest,
Shard::RetryPolicy::kNoRetry),
fromShard->runCommandWithIndefiniteRetries(
opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
xferModsRequest,
Shard::RetryPolicy::kNoRetry),
"_transferMods failed: ");
uassertStatusOKWithContext(
@ -1688,11 +1689,12 @@ void MigrationDestinationManager::_migrateDriver(OperationContext* outerOpCtx,
}
auto res = uassertStatusOKWithContext(
fromShard->runCommand(opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
xferModsRequest,
Shard::RetryPolicy::kNoRetry),
fromShard->runCommandWithIndefiniteRetries(
opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
xferModsRequest,
Shard::RetryPolicy::kNoRetry),
"_transferMods failed in STEADY STATE: ");
uassertStatusOKWithContext(Shard::CommandResponse::getEffectiveStatus(res),

View File

@ -606,7 +606,7 @@ void MigrationSourceManager::commitChunkMetadataOnConfig() {
Timer t;
auto commitChunkMigrationResponse =
Grid::get(_opCtx)->shardRegistry()->getConfigShard()->runCommandWithFixedRetryAttempts(
Grid::get(_opCtx)->shardRegistry()->getConfigShard()->runCommand(
_opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,

View File

@ -425,7 +425,7 @@ ExecutorFuture<void> launchReleaseCriticalSectionOnRecipientFuture(
"release migration critical section on recipient",
[&](OperationContext* newOpCtx) {
try {
const auto response = recipientShard->runCommandWithFixedRetryAttempts(
const auto response = recipientShard->runCommand(
newOpCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,

View File

@ -454,12 +454,12 @@ void setupZonesForTempNss(OperationContext* opCtx,
cmdBuilder.append("writeConcern", resharding::kMajorityWriteConcern.toBSON());
auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
auto cmdResponseStatus = uassertStatusOK(
configShard->runCommandWithFixedRetryAttempts(opCtx,
kPrimaryOnlyReadPreference,
DatabaseName::kAdmin,
cmdBuilder.obj(),
Shard::RetryPolicy::kIdempotent));
auto cmdResponseStatus =
uassertStatusOK(configShard->runCommand(opCtx,
kPrimaryOnlyReadPreference,
DatabaseName::kAdmin,
cmdBuilder.obj(),
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(cmdResponseStatus.commandStatus);
}
}

View File

@ -202,11 +202,12 @@ BSONObj getNextSessionOplogBatch(OperationContext* opCtx,
uassertStatusOK(shardStatus.getStatus());
auto shard = shardStatus.getValue();
auto responseStatus = shard->runCommand(opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
buildMigrateSessionCmd(migrationSessionId),
Shard::RetryPolicy::kNoRetry);
auto responseStatus =
shard->runCommandWithIndefiniteRetries(opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
buildMigrateSessionCmd(migrationSessionId),
Shard::RetryPolicy::kNoRetry);
uassertStatusOK(responseStatus.getStatus());
uassertStatusOK(responseStatus.getValue().commandStatus);

View File

@ -169,11 +169,12 @@ TEST_F(ConfigShardWrapperTest, RunCommandAttachesMinClusterTime) {
expectedMinClusterTime.addTicks(10);
VectorClock::get(operationContext())->advanceConfigTime_forTest(expectedMinClusterTime);
auto result = _configShardWrapper->runCommand(operationContext(),
ReadPreferenceSetting{},
DatabaseName::kConfig,
BSONObj{},
Shard::RetryPolicy::kNoRetry);
auto result =
_configShardWrapper->runCommandWithIndefiniteRetries(operationContext(),
ReadPreferenceSetting{},
DatabaseName::kConfig,
BSONObj{},
Shard::RetryPolicy::kNoRetry);
ASSERT_EQ(_mockConfigShard->lastReadPref.minClusterTime, expectedMinClusterTime.asTimestamp());
}

View File

@ -187,20 +187,23 @@ bool Shard::remoteIsRetriableError(ErrorCodes::Error code, RetryPolicy options)
MONGO_UNREACHABLE;
}
StatusWith<Shard::CommandResponse> Shard::runCommand(OperationContext* opCtx,
const ReadPreferenceSetting& readPref,
const DatabaseName& dbName,
const BSONObj& cmdObj,
RetryPolicy retryPolicy) {
return runCommand(opCtx, readPref, dbName, cmdObj, Milliseconds::max(), retryPolicy);
StatusWith<Shard::CommandResponse> Shard::runCommandWithIndefiniteRetries(
OperationContext* opCtx,
const ReadPreferenceSetting& readPref,
const DatabaseName& dbName,
const BSONObj& cmdObj,
RetryPolicy retryPolicy) {
return runCommandWithIndefiniteRetries(
opCtx, readPref, dbName, cmdObj, Milliseconds::max(), retryPolicy);
}
StatusWith<Shard::CommandResponse> Shard::runCommand(OperationContext* opCtx,
const ReadPreferenceSetting& readPref,
const DatabaseName& dbName,
const BSONObj& cmdObj,
Milliseconds maxTimeMSOverride,
RetryPolicy retryPolicy) {
StatusWith<Shard::CommandResponse> Shard::runCommandWithIndefiniteRetries(
OperationContext* opCtx,
const ReadPreferenceSetting& readPref,
const DatabaseName& dbName,
const BSONObj& cmdObj,
Milliseconds maxTimeMSOverride,
RetryPolicy retryPolicy) {
while (true) {
auto interruptStatus = opCtx->checkForInterruptNoAssert();
if (!interruptStatus.isOK()) {
@ -223,23 +226,20 @@ StatusWith<Shard::CommandResponse> Shard::runCommand(OperationContext* opCtx,
MONGO_UNREACHABLE;
}
StatusWith<Shard::CommandResponse> Shard::runCommandWithFixedRetryAttempts(
OperationContext* opCtx,
const ReadPreferenceSetting& readPref,
const DatabaseName& dbName,
const BSONObj& cmdObj,
RetryPolicy retryPolicy) {
return runCommandWithFixedRetryAttempts(
opCtx, readPref, dbName, cmdObj, Milliseconds::max(), retryPolicy);
StatusWith<Shard::CommandResponse> Shard::runCommand(OperationContext* opCtx,
const ReadPreferenceSetting& readPref,
const DatabaseName& dbName,
const BSONObj& cmdObj,
RetryPolicy retryPolicy) {
return runCommand(opCtx, readPref, dbName, cmdObj, Milliseconds::max(), retryPolicy);
}
StatusWith<Shard::CommandResponse> Shard::runCommandWithFixedRetryAttempts(
OperationContext* opCtx,
const ReadPreferenceSetting& readPref,
const DatabaseName& dbName,
const BSONObj& cmdObj,
Milliseconds maxTimeMSOverride,
RetryPolicy retryPolicy) {
StatusWith<Shard::CommandResponse> Shard::runCommand(OperationContext* opCtx,
const ReadPreferenceSetting& readPref,
const DatabaseName& dbName,
const BSONObj& cmdObj,
Milliseconds maxTimeMSOverride,
RetryPolicy retryPolicy) {
for (int retry = 1; retry <= kOnErrorNumRetries; ++retry) {
auto interruptStatus = opCtx->checkForInterruptNoAssert();
if (!interruptStatus.isOK()) {

View File

@ -214,6 +214,31 @@ public:
* given "retryPolicy". Retries indefinitely until/unless a non-retriable error is encountered,
* the maxTimeMs on the OperationContext expires, or the operation is interrupted.
*/
StatusWith<CommandResponse> runCommandWithIndefiniteRetries(
OperationContext* opCtx,
const ReadPreferenceSetting& readPref,
const DatabaseName& dbName,
const BSONObj& cmdObj,
RetryPolicy retryPolicy);
/**
* Same as the other variant of runCommandWithIndefiniteRetries, but allows the operation
* timeout to be overriden. Runs for the lesser of the remaining time on the operation
* context or the specified maxTimeMS override.
*/
StatusWith<CommandResponse> runCommandWithIndefiniteRetries(
OperationContext* opCtx,
const ReadPreferenceSetting& readPref,
const DatabaseName& dbName,
const BSONObj& cmdObj,
Milliseconds maxTimeMSOverride,
RetryPolicy retryPolicy);
/**
* Same as runCommandWithIndefiniteRetries, but will only retry failed operations up to 3
* times, regardless of the retryPolicy or the remaining maxTimeMs.
* Wherever possible this method should be avoided in favor of runCommandWithIndefiniteRetries.
*/
StatusWith<CommandResponse> runCommand(OperationContext* opCtx,
const ReadPreferenceSetting& readPref,
const DatabaseName& dbName,
@ -221,9 +246,9 @@ public:
RetryPolicy retryPolicy);
/**
* Same as the other variant of runCommand, but allows the operation timeout to be overriden.
* Runs for the lesser of the remaining time on the operation context or the specified maxTimeMS
* override.
* Same as runCommandWithIndefiniteRetries, but will only retry failed operations up to 3
* times, regardless of the retryPolicy or the remaining maxTimeMs.
* Wherever possible this method should be avoided in favor of runCommandWithIndefiniteRetries.
*/
StatusWith<CommandResponse> runCommand(OperationContext* opCtx,
const ReadPreferenceSetting& readPref,
@ -232,31 +257,6 @@ public:
Milliseconds maxTimeMSOverride,
RetryPolicy retryPolicy);
/**
* Same as runCommand, but will only retry failed operations up to 3 times, regardless of
* the retryPolicy or the remaining maxTimeMs.
* Wherever possible this method should be avoided in favor of runCommand.
*/
StatusWith<CommandResponse> runCommandWithFixedRetryAttempts(
OperationContext* opCtx,
const ReadPreferenceSetting& readPref,
const DatabaseName& dbName,
const BSONObj& cmdObj,
RetryPolicy retryPolicy);
/**
* Same as runCommand, but will only retry failed operations up to 3 times, regardless of
* the retryPolicy or the remaining maxTimeMs.
* Wherever possible this method should be avoided in favor of runCommand.
*/
StatusWith<CommandResponse> runCommandWithFixedRetryAttempts(
OperationContext* opCtx,
const ReadPreferenceSetting& readPref,
const DatabaseName& dbName,
const BSONObj& cmdObj,
Milliseconds maxTimeMSOverride,
RetryPolicy retryPolicy);
/**
* Schedules the command to be sent to the shard asynchronously. Does not provide any guarantee
* on whether the command is actually sent or even scheduled successfully.

View File

@ -93,23 +93,23 @@ protected:
void runDummyCommandOnShard(ShardId shardId) {
auto shard = unittest::assertGet(shardRegistry()->getShard(operationContext(), shardId));
uassertStatusOK(
shard->runCommand(operationContext(),
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::createDatabaseName_forTest(boost::none, "unusedDb"),
BSON("unused" << "cmd"),
Shard::RetryPolicy::kNoRetry));
uassertStatusOK(shard->runCommandWithIndefiniteRetries(
operationContext(),
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::createDatabaseName_forTest(boost::none, "unusedDb"),
BSON("unused" << "cmd"),
Shard::RetryPolicy::kNoRetry));
}
void runDummyCommandOnShardWithMaxTimeMS(ShardId shardId, Milliseconds maxTimeMS) {
auto shard = unittest::assertGet(shardRegistry()->getShard(operationContext(), shardId));
uassertStatusOK(
shard->runCommand(operationContext(),
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::createDatabaseName_forTest(boost::none, "unusedDb"),
BSON("unused" << "cmd"),
maxTimeMS,
Shard::RetryPolicy::kNoRetry));
uassertStatusOK(shard->runCommandWithIndefiniteRetries(
operationContext(),
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::createDatabaseName_forTest(boost::none, "unusedDb"),
BSON("unused" << "cmd"),
maxTimeMS,
Shard::RetryPolicy::kNoRetry));
}
inline static auto errorLabelsSystemOverloaded =

View File

@ -196,7 +196,7 @@ std::shared_ptr<Shard> ConfigServerTestFixture::getConfigShard() const {
Status ConfigServerTestFixture::insertToConfigCollection(OperationContext* opCtx,
const NamespaceString& ns,
const BSONObj& doc) {
auto insertResponse = getConfigShard()->runCommand(
auto insertResponse = getConfigShard()->runCommandWithIndefiniteRetries(
opCtx,
kReadPref,
ns.dbName(),
@ -218,7 +218,7 @@ Status ConfigServerTestFixture::updateToConfigCollection(OperationContext* opCtx
const BSONObj& query,
const BSONObj& update,
const bool upsert) {
auto updateResponse = getConfigShard()->runCommand(
auto updateResponse = getConfigShard()->runCommandWithIndefiniteRetries(
opCtx,
kReadPref,
ns.dbName(),
@ -246,7 +246,7 @@ Status ConfigServerTestFixture::deleteToConfigCollection(OperationContext* opCtx
const NamespaceString& ns,
const BSONObj& doc,
const bool multi) {
auto deleteResponse = getConfigShard()->runCommand(
auto deleteResponse = getConfigShard()->runCommandWithIndefiniteRetries(
opCtx,
kReadPref,
ns.dbName(),
@ -419,12 +419,13 @@ StatusWith<std::vector<BSONObj>> ConfigServerTestFixture::getIndexes(OperationCo
const NamespaceString& ns) {
auto configShard = getConfigShard();
auto response = configShard->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
ns.dbName(),
BSON("listIndexes" << ns.coll()),
Milliseconds(defaultConfigCommandTimeoutMS.load()),
Shard::RetryPolicy::kIdempotent);
auto response = configShard->runCommandWithIndefiniteRetries(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
ns.dbName(),
BSON("listIndexes" << ns.coll()),
Milliseconds(defaultConfigCommandTimeoutMS.load()),
Shard::RetryPolicy::kIdempotent);
if (!response.isOK()) {
return response.getStatus();
}

View File

@ -113,12 +113,11 @@ protected:
findAndModifyRequest.setWriteConcern(WriteConcernOptions(
WriteConcernOptions::kMajority, WriteConcernOptions::SyncMode::UNSET, Seconds(15)));
return _shardLocal->runCommandWithFixedRetryAttempts(
_opCtx.get(),
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
nss.dbName(),
findAndModifyRequest.toBSON(),
Shard::RetryPolicy::kNoRetry);
return _shardLocal->runCommand(_opCtx.get(),
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
nss.dbName(),
findAndModifyRequest.toBSON(),
Shard::RetryPolicy::kNoRetry);
}
/**
* Facilitates running a find query by supplying the redundant parameters. Finds documents in
@ -134,12 +133,11 @@ protected:
* Returns the index definitions that exist for the given collection.
*/
StatusWith<std::vector<BSONObj>> getIndexes(NamespaceString nss) {
auto response = _shardLocal->runCommandWithFixedRetryAttempts(
_opCtx.get(),
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
nss.dbName(),
BSON("listIndexes" << nss.coll()),
Shard::RetryPolicy::kIdempotent);
auto response = _shardLocal->runCommand(_opCtx.get(),
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
nss.dbName(),
BSON("listIndexes" << nss.coll()),
Shard::RetryPolicy::kIdempotent);
if (!response.isOK()) {
return response.getStatus();
}

View File

@ -215,13 +215,12 @@ Status ShardingLogging::_createCappedConfigCollection(OperationContext* opCtx,
<< WriteConcernOptions::kWriteConcernField << writeConcern.toBSON());
while (true) {
auto result = configShard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kConfig,
createCmd,
Milliseconds(defaultConfigCommandTimeoutMS.load()),
Shard::RetryPolicy::kIdempotent);
auto result = configShard->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kConfig,
createCmd,
Milliseconds(defaultConfigCommandTimeoutMS.load()),
Shard::RetryPolicy::kIdempotent);
if (!result.isOK()) {
return result.getStatus();

View File

@ -82,19 +82,16 @@ public:
configsvrRequest.setDbName(request().getDbName());
const auto cmdResponseWithStatus =
Grid::get(opCtx)
->shardRegistry()
->getConfigShard()
->runCommandWithFixedRetryAttempts(
opCtx,
kPrimaryOnlyReadPreference,
DatabaseName::kAdmin,
// TODO SERVER-91373: Remove appendMajorityWriteConcern
CommandHelpers::appendMajorityWriteConcern(
CommandHelpers::filterCommandRequestForPassthrough(
configsvrRequest.toBSON()),
opCtx->getWriteConcern()),
Shard::RetryPolicy::kIdempotent);
Grid::get(opCtx)->shardRegistry()->getConfigShard()->runCommand(
opCtx,
kPrimaryOnlyReadPreference,
DatabaseName::kAdmin,
// TODO SERVER-91373: Remove appendMajorityWriteConcern
CommandHelpers::appendMajorityWriteConcern(
CommandHelpers::filterCommandRequestForPassthrough(
configsvrRequest.toBSON()),
opCtx->getWriteConcern()),
Shard::RetryPolicy::kIdempotent);
Grid::get(opCtx)->shardRegistry()->reload(opCtx);

View File

@ -71,19 +71,16 @@ public:
configsvrRequest.setDbName(request().getDbName());
const auto cmdResponseWithStatus =
Grid::get(opCtx)
->shardRegistry()
->getConfigShard()
->runCommandWithFixedRetryAttempts(
opCtx,
kPrimaryOnlyReadPreference,
DatabaseName::kAdmin,
// TODO SERVER-91373: Remove appendMajorityWriteConcern
CommandHelpers::appendMajorityWriteConcern(
CommandHelpers::filterCommandRequestForPassthrough(
configsvrRequest.toBSON()),
opCtx->getWriteConcern()),
Shard::RetryPolicy::kIdempotent);
Grid::get(opCtx)->shardRegistry()->getConfigShard()->runCommand(
opCtx,
kPrimaryOnlyReadPreference,
DatabaseName::kAdmin,
// TODO SERVER-91373: Remove appendMajorityWriteConcern
CommandHelpers::appendMajorityWriteConcern(
CommandHelpers::filterCommandRequestForPassthrough(
configsvrRequest.toBSON()),
opCtx->getWriteConcern()),
Shard::RetryPolicy::kIdempotent);
uassertStatusOK(cmdResponseWithStatus.getValue().commandStatus);
}

View File

@ -120,7 +120,7 @@ public:
generic_argument_util::setMajorityWriteConcern(configsvrRequest, &opCtx->getWriteConcern());
auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
auto cmdResponseStatus = uassertStatusOK(configShard->runCommandWithFixedRetryAttempts(
auto cmdResponseStatus = uassertStatusOK(configShard->runCommand(
opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,

View File

@ -72,16 +72,12 @@ public:
configsvrRequest.setDbName(request().getDbName());
const auto cmdResponseWithStatus =
Grid::get(opCtx)
->shardRegistry()
->getConfigShard()
->runCommandWithFixedRetryAttempts(
opCtx,
kPrimaryOnlyReadPreference,
DatabaseName::kAdmin,
CommandHelpers::filterCommandRequestForPassthrough(
configsvrRequest.toBSON()),
Shard::RetryPolicy::kIdempotent);
Grid::get(opCtx)->shardRegistry()->getConfigShard()->runCommand(
opCtx,
kPrimaryOnlyReadPreference,
DatabaseName::kAdmin,
CommandHelpers::filterCommandRequestForPassthrough(configsvrRequest.toBSON()),
Shard::RetryPolicy::kIdempotent);
const auto cmdResponse = uassertStatusOK(cmdResponseWithStatus);
uassertStatusOK(cmdResponseWithStatus.getValue().commandStatus);

View File

@ -71,19 +71,16 @@ public:
configsvrRequest.setDbName(request().getDbName());
const auto cmdResponseWithStatus =
Grid::get(opCtx)
->shardRegistry()
->getConfigShard()
->runCommandWithFixedRetryAttempts(
opCtx,
kPrimaryOnlyReadPreference,
DatabaseName::kAdmin,
// TODO SERVER-91373: Remove appendMajorityWriteConcern
CommandHelpers::appendMajorityWriteConcern(
CommandHelpers::filterCommandRequestForPassthrough(
configsvrRequest.toBSON()),
opCtx->getWriteConcern()),
Shard::RetryPolicy::kIdempotent);
Grid::get(opCtx)->shardRegistry()->getConfigShard()->runCommand(
opCtx,
kPrimaryOnlyReadPreference,
DatabaseName::kAdmin,
// TODO SERVER-91373: Remove appendMajorityWriteConcern
CommandHelpers::appendMajorityWriteConcern(
CommandHelpers::filterCommandRequestForPassthrough(
configsvrRequest.toBSON()),
opCtx->getWriteConcern()),
Shard::RetryPolicy::kIdempotent);
uassertStatusOK(cmdResponseWithStatus.getValue().commandStatus);
}

View File

@ -70,19 +70,16 @@ public:
configsvrRequest.setDbName(request().getDbName());
const auto cmdResponseWithStatus =
Grid::get(opCtx)
->shardRegistry()
->getConfigShard()
->runCommandWithFixedRetryAttempts(
opCtx,
kPrimaryOnlyReadPreference,
DatabaseName::kAdmin,
// TODO SERVER-91373: Remove appendMajorityWriteConcern
CommandHelpers::appendMajorityWriteConcern(
CommandHelpers::filterCommandRequestForPassthrough(
configsvrRequest.toBSON()),
opCtx->getWriteConcern()),
Shard::RetryPolicy::kIdempotent);
Grid::get(opCtx)->shardRegistry()->getConfigShard()->runCommand(
opCtx,
kPrimaryOnlyReadPreference,
DatabaseName::kAdmin,
// TODO SERVER-91373: Remove appendMajorityWriteConcern
CommandHelpers::appendMajorityWriteConcern(
CommandHelpers::filterCommandRequestForPassthrough(
configsvrRequest.toBSON()),
opCtx->getWriteConcern()),
Shard::RetryPolicy::kIdempotent);
uassertStatusOK(cmdResponseWithStatus.getValue().commandStatus);
}

View File

@ -569,11 +569,11 @@ SharedSemiFuture<ShardRegistry::Cache::ValueHandle> ShardRegistry::_reloadAsync(
Status ShardRegistry::_pingForNewTopologyTime(OperationContext* opCtx) {
return getConfigShard()
->runCommand(opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryPreferred),
DatabaseName::kAdmin,
BSON("ping" << 1),
Shard::RetryPolicy::kNoRetry)
->runCommandWithIndefiniteRetries(opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryPreferred),
DatabaseName::kAdmin,
BSON("ping" << 1),
Shard::RetryPolicy::kNoRetry)
.getStatus();
}

View File

@ -1400,7 +1400,7 @@ long long runCountCommandOnConfig(OperationContext* opCtx,
countBuilder.append("count", nss.coll());
countBuilder.append("query", query);
auto resultStatus = localConfigShard->runCommandWithFixedRetryAttempts(
auto resultStatus = localConfigShard->runCommand(
opCtx,
kConfigReadSelector,
nss.dbName(),
@ -1677,7 +1677,7 @@ void updateClusterCardinalityParameter(const Lock::ExclusiveLock&, OperationCont
configsvrSetClusterParameter.set_compatibleWithTopologyChange(true);
while (true) {
const auto cmdResponse = shardRegistry->getConfigShard()->runCommandWithFixedRetryAttempts(
const auto cmdResponse = shardRegistry->getConfigShard()->runCommand(
opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,

View File

@ -86,12 +86,12 @@ public:
&opCtx->getWriteConcern());
auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
auto cmdResponse = uassertStatusOK(configShard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
configsvrSetUserWriteBlockModeCmd.toBSON(),
Shard::RetryPolicy::kIdempotent));
auto cmdResponse = uassertStatusOK(
configShard->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
configsvrSetUserWriteBlockModeCmd.toBSON(),
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(cmdResponse.commandStatus);
uassertStatusOK(cmdResponse.writeConcernStatus);
}

View File

@ -41,13 +41,13 @@ HistoricalPlacement HistoricalPlacementFetcherImpl::fetch(
ConfigsvrGetHistoricalPlacement request(nss.value_or(NamespaceString::kEmpty), atClusterTime);
auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
auto remoteResponse = uassertStatusOK(configShard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
request.toBSON(),
Milliseconds(defaultConfigCommandTimeoutMS.load()),
Shard::RetryPolicy::kIdempotentOrCursorInvalidated));
auto remoteResponse = uassertStatusOK(
configShard->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
request.toBSON(),
Milliseconds(defaultConfigCommandTimeoutMS.load()),
Shard::RetryPolicy::kIdempotentOrCursorInvalidated));
uassertStatusOK(remoteResponse.commandStatus);
return ConfigsvrGetHistoricalPlacementResponse::parse(

View File

@ -83,12 +83,12 @@ public:
}
auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
auto cmdResponse = uassertStatusOK(configShard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
configsvrAbortReshardCollection.toBSON(),
Shard::RetryPolicy::kIdempotent));
auto cmdResponse = uassertStatusOK(
configShard->runCommand(opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
configsvrAbortReshardCollection.toBSON(),
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(cmdResponse.commandStatus);
uassertStatusOK(cmdResponse.writeConcernStatus);
}

View File

@ -73,12 +73,12 @@ public:
configsvrRequest.setDbName(request().getDbName());
auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
auto cmdResponse = uassertStatusOK(configShard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
configsvrRequest.toBSON(),
Shard::RetryPolicy::kIdempotent));
auto cmdResponse = uassertStatusOK(
configShard->runCommand(opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
configsvrRequest.toBSON(),
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(cmdResponse.commandStatus);

View File

@ -71,12 +71,12 @@ public:
configsvrCleanupReshardCollection.setDbName(request().getDbName());
auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
auto cmdResponse = uassertStatusOK(configShard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
configsvrCleanupReshardCollection.toBSON(),
Shard::RetryPolicy::kIdempotent));
auto cmdResponse = uassertStatusOK(
configShard->runCommand(opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
configsvrCleanupReshardCollection.toBSON(),
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(cmdResponse.commandStatus);
uassertStatusOK(cmdResponse.writeConcernStatus);
}

View File

@ -141,12 +141,12 @@ public:
generic_argument_util::setMajorityWriteConcern(configCmd, &opCtx->getWriteConcern());
auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
auto cmdResponse = uassertStatusOK(configShard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
configCmd.toBSON(),
Shard::RetryPolicy::kIdempotent));
auto cmdResponse = uassertStatusOK(
configShard->runCommand(opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
configCmd.toBSON(),
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(cmdResponse.commandStatus);
uassertStatusOK(cmdResponse.writeConcernStatus);

View File

@ -77,12 +77,12 @@ public:
configsvrRequest.setDbName(request().getDbName());
auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
auto cmdResponse = uassertStatusOK(configShard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
configsvrRequest.toBSON(),
Shard::RetryPolicy::kIdempotent));
auto cmdResponse = uassertStatusOK(
configShard->runCommand(opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
configsvrRequest.toBSON(),
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(cmdResponse.commandStatus);
}

View File

@ -112,12 +112,12 @@ public:
"About to run balancer control command",
"cmd"_attr = _configsvrCommandName);
auto cmdResponse = uassertStatusOK(
configShard->runCommandWithFixedRetryAttempts(opCtx,
kPrimaryOnlyReadPreference,
DatabaseName::kAdmin,
BSON(_configsvrCommandName << 1),
Shard::RetryPolicy::kIdempotent));
auto cmdResponse =
uassertStatusOK(configShard->runCommand(opCtx,
kPrimaryOnlyReadPreference,
DatabaseName::kAdmin,
BSON(_configsvrCommandName << 1),
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(cmdResponse.commandStatus);
// Append any return value from the response, which the config server returned

View File

@ -121,11 +121,11 @@ private:
auto cmdToSend = BSON("killOp" << 1 << "op" << opId);
shard
->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
cmdToSend,
Shard::RetryPolicy::kNoRetry)
->runCommandWithIndefiniteRetries(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
cmdToSend,
Shard::RetryPolicy::kNoRetry)
.getStatus()
.ignore();

View File

@ -230,12 +230,12 @@ public:
generic_argument_util::setMajorityWriteConcern(configsvrRequest);
auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
auto commandResponse =
configShard->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
configsvrRequest.toBSON(),
Shard::RetryPolicy::kIdempotent);
auto commandResponse = configShard->runCommandWithIndefiniteRetries(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
configsvrRequest.toBSON(),
Shard::RetryPolicy::kIdempotent);
uassertStatusOK(Shard::CommandResponse::getEffectiveStatus(std::move(commandResponse)));
Grid::get(opCtx)->catalogCache()->onStaleCollectionVersion(ns(), boost::none);

View File

@ -100,12 +100,13 @@ public:
configsvrRequest.setWriteConcern(opCtx->getWriteConcern());
auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
const auto commandResponse = uassertStatusOK(
configShard->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
configsvrRequest.toBSON(),
Shard::RetryPolicy::kIdempotent));
const auto commandResponse =
uassertStatusOK(configShard->runCommandWithIndefiniteRetries(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
configsvrRequest.toBSON(),
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(Shard::CommandResponse::getEffectiveStatus(commandResponse));
}

View File

@ -105,7 +105,7 @@ public:
SetQuerySettingsCommandReply typedRun(OperationContext* opCtx) {
const auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
const auto cmdResponse = uassertStatusOK(configShard->runCommandWithFixedRetryAttempts(
const auto cmdResponse = uassertStatusOK(configShard->runCommand(
opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
@ -168,7 +168,7 @@ public:
void typedRun(OperationContext* opCtx) {
const auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
const auto cmdResponse = uassertStatusOK(configShard->runCommandWithFixedRetryAttempts(
const auto cmdResponse = uassertStatusOK(configShard->runCommand(
opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,

View File

@ -83,15 +83,15 @@ public:
const BSONObj& cmdObj,
BSONObjBuilder& result) override {
auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
auto cmdResponse = uassertStatusOK(configShard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
// TODO SERVER-91373: Remove appendMajorityWriteConcern
CommandHelpers::appendMajorityWriteConcern(
CommandHelpers::filterCommandRequestForPassthrough(cmdObj),
opCtx->getWriteConcern()),
Shard::RetryPolicy::kNotIdempotent));
auto cmdResponse = uassertStatusOK(
configShard->runCommand(opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
// TODO SERVER-91373: Remove appendMajorityWriteConcern
CommandHelpers::appendMajorityWriteConcern(
CommandHelpers::filterCommandRequestForPassthrough(cmdObj),
opCtx->getWriteConcern()),
Shard::RetryPolicy::kNotIdempotent));
CommandHelpers::filterCommandReplyForPassthrough(cmdResponse.response, &result);
@ -176,12 +176,12 @@ public:
setReadWriteConcern(opCtx, configsvrRequest, this);
auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
auto cmdResponse = uassertStatusOK(configShard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
configsvrRequest.toBSON(),
Shard::RetryPolicy::kIdempotent));
auto cmdResponse = uassertStatusOK(
configShard->runCommand(opCtx,
ReadPreferenceSetting(ReadPreference::PrimaryOnly),
DatabaseName::kAdmin,
configsvrRequest.toBSON(),
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(cmdResponse.commandStatus);

View File

@ -110,7 +110,7 @@ public:
// Forward to config shard, which will forward to all shards.
auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
auto response = uassertStatusOK(configShard->runCommandWithFixedRetryAttempts(
auto response = uassertStatusOK(configShard->runCommand(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
cmd.getDbName(),

View File

@ -98,12 +98,12 @@ BSONObj selectMedianKey(OperationContext* opCtx,
auto shard = uassertStatusOK(Grid::get(opCtx)->shardRegistry()->getShard(opCtx, shardId));
auto cmdResponse = uassertStatusOK(
shard->runCommandWithFixedRetryAttempts(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
cmd.obj(),
Shard::RetryPolicy::kIdempotent));
auto cmdResponse =
uassertStatusOK(shard->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
cmd.obj(),
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(cmdResponse.commandStatus);

View File

@ -92,12 +92,11 @@ public:
auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
// Force a reload of this node's shard list cache at the end of this command.
auto cmdResponseWithStatus =
configShard->runCommandWithFixedRetryAttempts(opCtx,
kPrimaryOnlyReadPreference,
DatabaseName::kAdmin,
cmdToSend.toBSON(),
Shard::RetryPolicy::kIdempotent);
auto cmdResponseWithStatus = configShard->runCommand(opCtx,
kPrimaryOnlyReadPreference,
DatabaseName::kAdmin,
cmdToSend.toBSON(),
Shard::RetryPolicy::kIdempotent);
Grid::get(opCtx)->shardRegistry()->reload(opCtx);

View File

@ -90,13 +90,13 @@ public:
// Force a reload of this node's shard list cache at the end of this command.
auto cmdResponseWithStatus = configShard->runCommandWithFixedRetryAttempts(
opCtx,
kPrimaryOnlyReadPreference,
DatabaseName::kAdmin,
CommandHelpers::filterCommandRequestForPassthrough(
transitionToDedicatedConfigServer.toBSON()),
Shard::RetryPolicy::kIdempotent);
auto cmdResponseWithStatus =
configShard->runCommand(opCtx,
kPrimaryOnlyReadPreference,
DatabaseName::kAdmin,
CommandHelpers::filterCommandRequestForPassthrough(
transitionToDedicatedConfigServer.toBSON()),
Shard::RetryPolicy::kIdempotent);
Grid::get(opCtx)->shardRegistry()->reload(opCtx);

View File

@ -75,12 +75,12 @@ public:
cmd.serialize(&cmdBuilder);
auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
auto cmdResponseStatus = uassertStatusOK(
configShard->runCommandWithFixedRetryAttempts(opCtx,
kPrimaryOnlyReadPreference,
DatabaseName::kAdmin,
cmdBuilder.obj(),
Shard::RetryPolicy::kIdempotent));
auto cmdResponseStatus =
uassertStatusOK(configShard->runCommand(opCtx,
kPrimaryOnlyReadPreference,
DatabaseName::kAdmin,
cmdBuilder.obj(),
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(cmdResponseStatus.commandStatus);
}

View File

@ -109,12 +109,12 @@ StatusWith<std::vector<CollectionQueryAnalyzerConfiguration>> executeRefreshComm
if (serverGlobalParams.clusterRole.hasExclusively(ClusterRole::RouterServer) ||
serverGlobalParams.clusterRole.has(ClusterRole::ShardServer)) {
const auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
auto swResponse = configShard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
cmd.toBSON(),
Shard::RetryPolicy::kIdempotent);
auto swResponse =
configShard->runCommand(opCtx,
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
DatabaseName::kAdmin,
cmd.toBSON(),
Shard::RetryPolicy::kIdempotent);
if (auto status = Shard::CommandResponse::getEffectiveStatus(swResponse); !status.isOK()) {
return status;
}

View File

@ -51,12 +51,12 @@ boost::optional<RWConcernDefault> readWriteConcernDefaultsCacheLookupMongoS(
configsvrRequest.setDbName(DatabaseName::kAdmin);
auto configShard = Grid::get(opCtx)->shardRegistry()->getConfigShard();
auto cmdResponse = uassertStatusOK(configShard->runCommandWithFixedRetryAttempts(
opCtx,
ReadPreferenceSetting(ReadPreference::Nearest),
DatabaseName::kAdmin,
configsvrRequest.toBSON(),
Shard::RetryPolicy::kIdempotent));
auto cmdResponse =
uassertStatusOK(configShard->runCommand(opCtx,
ReadPreferenceSetting(ReadPreference::Nearest),
DatabaseName::kAdmin,
configsvrRequest.toBSON(),
Shard::RetryPolicy::kIdempotent));
uassertStatusOK(cmdResponse.commandStatus);