diff options
Diffstat (limited to 'src/mongo/db/s/config')
15 files changed, 28 insertions, 53 deletions
diff --git a/src/mongo/db/s/config/configsvr_abort_reshard_collection_command.cpp b/src/mongo/db/s/config/configsvr_abort_reshard_collection_command.cpp index 7a5653bb594..9cb503a2979 100644 --- a/src/mongo/db/s/config/configsvr_abort_reshard_collection_command.cpp +++ b/src/mongo/db/s/config/configsvr_abort_reshard_collection_command.cpp @@ -107,9 +107,8 @@ public: uassert(ErrorCodes::IllegalOperation, "_configsvrAbortReshardCollection can only be run on config servers", serverGlobalParams.clusterRole == ClusterRole::ConfigServer); - uassert(ErrorCodes::InvalidOptions, - "_configsvrAbortReshardCollection must be called with majority writeConcern", - opCtx->getWriteConcern().wMode == WriteConcernOptions::kMajority); + CommandHelpers::uassertCommandRunWithMajority(Request::kCommandName, + opCtx->getWriteConcern()); const auto reshardingUUID = retrieveReshardingUUID(opCtx, ns()); diff --git a/src/mongo/db/s/config/configsvr_add_shard_command.cpp b/src/mongo/db/s/config/configsvr_add_shard_command.cpp index 7504b149e50..7e45c082250 100644 --- a/src/mongo/db/s/config/configsvr_add_shard_command.cpp +++ b/src/mongo/db/s/config/configsvr_add_shard_command.cpp @@ -98,11 +98,7 @@ public: uassert(ErrorCodes::IllegalOperation, "_configsvrAddShard can only be run on config servers", serverGlobalParams.clusterRole == ClusterRole::ConfigServer); - uassert( - ErrorCodes::InvalidOptions, - str::stream() << "_configsvrAddShard must be called with majority writeConcern, got " - << cmdObj, - opCtx->getWriteConcern().wMode == WriteConcernOptions::kMajority); + CommandHelpers::uassertCommandRunWithMajority(getName(), opCtx->getWriteConcern()); // Set the operation context read concern level to local for reads into the config database. repl::ReadConcernArgs::get(opCtx) = diff --git a/src/mongo/db/s/config/configsvr_clear_jumbo_flag_command.cpp b/src/mongo/db/s/config/configsvr_clear_jumbo_flag_command.cpp index 9f4a3a07cc2..f97d164151b 100644 --- a/src/mongo/db/s/config/configsvr_clear_jumbo_flag_command.cpp +++ b/src/mongo/db/s/config/configsvr_clear_jumbo_flag_command.cpp @@ -57,9 +57,8 @@ public: uassert(ErrorCodes::IllegalOperation, "_configsvrClearJumboFlag can only be run on config servers", serverGlobalParams.clusterRole == ClusterRole::ConfigServer); - uassert(ErrorCodes::InvalidOptions, - "_configsvrClearJumboFlag must be called with majority writeConcern", - opCtx->getWriteConcern().wMode == WriteConcernOptions::kMajority); + CommandHelpers::uassertCommandRunWithMajority(Request::kCommandName, + opCtx->getWriteConcern()); // Set the operation context read concern level to local for reads into the config // database. diff --git a/src/mongo/db/s/config/configsvr_commit_reshard_collection_command.cpp b/src/mongo/db/s/config/configsvr_commit_reshard_collection_command.cpp index 6cf6440a36f..fb67df820c4 100644 --- a/src/mongo/db/s/config/configsvr_commit_reshard_collection_command.cpp +++ b/src/mongo/db/s/config/configsvr_commit_reshard_collection_command.cpp @@ -79,10 +79,8 @@ public: ErrorCodes::IllegalOperation, format(FMT_STRING("{} can only be run on config servers"), definition()->getName()), serverGlobalParams.clusterRole == ClusterRole::ConfigServer); - uassert(ErrorCodes::InvalidOptions, - format(FMT_STRING("{} must be called with majority writeConcern"), - definition()->getName()), - opCtx->getWriteConcern().wMode == WriteConcernOptions::kMajority); + CommandHelpers::uassertCommandRunWithMajority(Request::kCommandName, + opCtx->getWriteConcern()); UUID reshardingUUID = retrieveReshardingUUID(opCtx, ns()); diff --git a/src/mongo/db/s/config/configsvr_create_database_command.cpp b/src/mongo/db/s/config/configsvr_create_database_command.cpp index 86d2c81607d..83e9271954f 100644 --- a/src/mongo/db/s/config/configsvr_create_database_command.cpp +++ b/src/mongo/db/s/config/configsvr_create_database_command.cpp @@ -71,10 +71,8 @@ public: uassert(ErrorCodes::IllegalOperation, "_configsvrCreateDatabase can only be run on config servers", serverGlobalParams.clusterRole == ClusterRole::ConfigServer); - uassert(ErrorCodes::InvalidOptions, - str::stream() - << "_configsvrCreateDatabase must be called with majority writeConcern", - opCtx->getWriteConcern().wMode == WriteConcernOptions::kMajority); + CommandHelpers::uassertCommandRunWithMajority(Request::kCommandName, + opCtx->getWriteConcern()); // Set the operation context read concern level to local for reads into the config // database. diff --git a/src/mongo/db/s/config/configsvr_ensure_chunk_version_is_greater_than_command.cpp b/src/mongo/db/s/config/configsvr_ensure_chunk_version_is_greater_than_command.cpp index 1b39374f9da..9acbfb2f107 100644 --- a/src/mongo/db/s/config/configsvr_ensure_chunk_version_is_greater_than_command.cpp +++ b/src/mongo/db/s/config/configsvr_ensure_chunk_version_is_greater_than_command.cpp @@ -52,10 +52,8 @@ public: uassert(ErrorCodes::IllegalOperation, "_configsvrEnsureChunkVersionIsGreaterThan can only be run on config servers", serverGlobalParams.clusterRole == ClusterRole::ConfigServer); - uassert(ErrorCodes::InvalidOptions, - "_configsvrEnsureChunkVersionIsGreaterThan must be called with majority " - "writeConcern", - opCtx->getWriteConcern().wMode == WriteConcernOptions::kMajority); + CommandHelpers::uassertCommandRunWithMajority(Request::kCommandName, + opCtx->getWriteConcern()); ShardingCatalogManager::get(opCtx)->ensureChunkVersionIsGreaterThan( opCtx, request().getCollectionUUID(), diff --git a/src/mongo/db/s/config/configsvr_refine_collection_shard_key_command.cpp b/src/mongo/db/s/config/configsvr_refine_collection_shard_key_command.cpp index ef766dd1d68..a58168f06be 100644 --- a/src/mongo/db/s/config/configsvr_refine_collection_shard_key_command.cpp +++ b/src/mongo/db/s/config/configsvr_refine_collection_shard_key_command.cpp @@ -56,9 +56,8 @@ public: uassert(ErrorCodes::IllegalOperation, "_configsvrRefineCollectionShardKey can only be run on config servers", serverGlobalParams.clusterRole == ClusterRole::ConfigServer); - uassert(ErrorCodes::InvalidOptions, - "_configsvrRefineCollectionShardKey must be called with majority writeConcern", - opCtx->getWriteConcern().wMode == WriteConcernOptions::kMajority); + CommandHelpers::uassertCommandRunWithMajority(Request::kCommandName, + opCtx->getWriteConcern()); _internalRun(opCtx); } diff --git a/src/mongo/db/s/config/configsvr_remove_chunks_command.cpp b/src/mongo/db/s/config/configsvr_remove_chunks_command.cpp index 77289aa3100..c08c93b9d8e 100644 --- a/src/mongo/db/s/config/configsvr_remove_chunks_command.cpp +++ b/src/mongo/db/s/config/configsvr_remove_chunks_command.cpp @@ -62,9 +62,8 @@ public: uassert(ErrorCodes::IllegalOperation, "_configsvrRemoveChunks can only be run on config servers", serverGlobalParams.clusterRole == ClusterRole::ConfigServer); - uassert(ErrorCodes::InvalidOptions, - "_configsvrRemoveChunks must be called with majority writeConcern", - opCtx->getWriteConcern().wMode == WriteConcernOptions::kMajority); + CommandHelpers::uassertCommandRunWithMajority(Request::kCommandName, + opCtx->getWriteConcern()); // Set the operation context read concern level to local for reads into the config // database. diff --git a/src/mongo/db/s/config/configsvr_remove_shard_command.cpp b/src/mongo/db/s/config/configsvr_remove_shard_command.cpp index 16e74bb3dbf..73ad8dcbb21 100644 --- a/src/mongo/db/s/config/configsvr_remove_shard_command.cpp +++ b/src/mongo/db/s/config/configsvr_remove_shard_command.cpp @@ -99,11 +99,7 @@ public: uassert(ErrorCodes::IllegalOperation, "_configsvrRemoveShard can only be run on config servers", serverGlobalParams.clusterRole == ClusterRole::ConfigServer); - uassert( - ErrorCodes::InvalidOptions, - str::stream() << "_configsvrRemoveShard must be called with majority writeConcern, got " - << cmdObj, - opCtx->getWriteConcern().wMode == WriteConcernOptions::kMajority); + CommandHelpers::uassertCommandRunWithMajority(getName(), opCtx->getWriteConcern()); ON_BLOCK_EXIT([&opCtx] { repl::ReplClientInfo::forClient(opCtx->getClient()).setLastOpToSystemLastOpTime(opCtx); diff --git a/src/mongo/db/s/config/configsvr_remove_tags_command.cpp b/src/mongo/db/s/config/configsvr_remove_tags_command.cpp index 9bf9dbed174..ce1afe24e15 100644 --- a/src/mongo/db/s/config/configsvr_remove_tags_command.cpp +++ b/src/mongo/db/s/config/configsvr_remove_tags_command.cpp @@ -62,9 +62,8 @@ public: uassert(ErrorCodes::IllegalOperation, "_configsvrRemoveTags can only be run on config servers", serverGlobalParams.clusterRole == ClusterRole::ConfigServer); - uassert(ErrorCodes::InvalidOptions, - "_configsvrRemoveTags must be called with majority writeConcern", - opCtx->getWriteConcern().wMode == WriteConcernOptions::kMajority); + CommandHelpers::uassertCommandRunWithMajority(Request::kCommandName, + opCtx->getWriteConcern()); // Set the operation context read concern level to local for reads into the config // database. diff --git a/src/mongo/db/s/config/configsvr_rename_collection_metadata_command.cpp b/src/mongo/db/s/config/configsvr_rename_collection_metadata_command.cpp index 854f6e359e4..87a069ec3f4 100644 --- a/src/mongo/db/s/config/configsvr_rename_collection_metadata_command.cpp +++ b/src/mongo/db/s/config/configsvr_rename_collection_metadata_command.cpp @@ -75,9 +75,8 @@ public: uassert(ErrorCodes::IllegalOperation, "_configsvrRenameCollectionMetadata can only be run on config servers", serverGlobalParams.clusterRole == ClusterRole::ConfigServer); - uassert(ErrorCodes::InvalidOptions, - "_configsvrRenameCollectionMetadata must be called with majority writeConcern", - opCtx->getWriteConcern().wMode == WriteConcernOptions::kMajority); + CommandHelpers::uassertCommandRunWithMajority(Request::kCommandName, + opCtx->getWriteConcern()); opCtx->setAlwaysInterruptAtStepDownOrUp(); diff --git a/src/mongo/db/s/config/configsvr_repair_sharded_collection_chunks_history_command.cpp b/src/mongo/db/s/config/configsvr_repair_sharded_collection_chunks_history_command.cpp index 4586c03cc68..615e1098ccc 100644 --- a/src/mongo/db/s/config/configsvr_repair_sharded_collection_chunks_history_command.cpp +++ b/src/mongo/db/s/config/configsvr_repair_sharded_collection_chunks_history_command.cpp @@ -92,11 +92,7 @@ public: repl::ReadConcernArgs::get(opCtx) = repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern); - uassert(ErrorCodes::InvalidOptions, - str::stream() << "_configsvrRepairShardedCollectionChunksHistory must be called " - "with majority writeConcern, got " - << cmdObj, - opCtx->getWriteConcern().wMode == WriteConcernOptions::kMajority); + CommandHelpers::uassertCommandRunWithMajority(getName(), opCtx->getWriteConcern()); const NamespaceString nss{parseNs(unusedDbName, cmdObj)}; diff --git a/src/mongo/db/s/config/configsvr_reshard_collection_cmd.cpp b/src/mongo/db/s/config/configsvr_reshard_collection_cmd.cpp index c98393c64dd..55bcaa9bbd1 100644 --- a/src/mongo/db/s/config/configsvr_reshard_collection_cmd.cpp +++ b/src/mongo/db/s/config/configsvr_reshard_collection_cmd.cpp @@ -91,9 +91,8 @@ public: uassert(ErrorCodes::IllegalOperation, "_configsvrReshardCollection can only be run on config servers", serverGlobalParams.clusterRole == ClusterRole::ConfigServer); - uassert(ErrorCodes::InvalidOptions, - "_configsvrReshardCollection must be called with majority writeConcern", - opCtx->getWriteConcern().wMode == WriteConcernOptions::kMajority); + CommandHelpers::uassertCommandRunWithMajority(Request::kCommandName, + opCtx->getWriteConcern()); repl::ReadConcernArgs::get(opCtx) = repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern); diff --git a/src/mongo/db/s/config/configsvr_set_allow_migrations_command.cpp b/src/mongo/db/s/config/configsvr_set_allow_migrations_command.cpp index f70df3d9d9f..01c3032aa40 100644 --- a/src/mongo/db/s/config/configsvr_set_allow_migrations_command.cpp +++ b/src/mongo/db/s/config/configsvr_set_allow_migrations_command.cpp @@ -56,9 +56,8 @@ public: uassert(ErrorCodes::IllegalOperation, "_configsvrSetAllowMigrations can only be run on config servers", serverGlobalParams.clusterRole == ClusterRole::ConfigServer); - uassert(ErrorCodes::InvalidOptions, - "_configsvrSetAllowMigrations must be called with majority writeConcern", - opCtx->getWriteConcern().wMode == WriteConcernOptions::kMajority); + CommandHelpers::uassertCommandRunWithMajority(Request::kCommandName, + opCtx->getWriteConcern()); // Set the operation context read concern level to local for reads into the config // database. diff --git a/src/mongo/db/s/config/sharding_catalog_manager_collection_operations.cpp b/src/mongo/db/s/config/sharding_catalog_manager_collection_operations.cpp index de70ad64fd7..0a103392946 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager_collection_operations.cpp +++ b/src/mongo/db/s/config/sharding_catalog_manager_collection_operations.cpp @@ -495,8 +495,9 @@ void ShardingCatalogManager::refineCollectionShardKey(OperationContext* opCtx, // documents than a normal operation, so we override the write concern to not use a // wTimeout, matching the behavior before the API was introduced. WriteConcernOptions originalWC = opCtx->getWriteConcern(); - opCtx->setWriteConcern(WriteConcernOptions( - WriteConcernOptions::kMajority, WriteConcernOptions::SyncMode::UNSET, 0)); + opCtx->setWriteConcern(WriteConcernOptions{WriteConcernOptions::kMajority, + WriteConcernOptions::SyncMode::UNSET, + WriteConcernOptions::kNoTimeout}); ON_BLOCK_EXIT([opCtx, originalWC] { opCtx->setWriteConcern(originalWC); }); withTransactionAPI(opCtx, nss, std::move(updateCollectionAndChunksWithAPIFn)); |