summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorBlake Oler <blake.oler@mongodb.com>2018-04-02 15:45:58 -0400
committerBlake Oler <blake.oler@mongodb.com>2018-05-10 15:08:44 -0400
commitec4a3883899f3ea9f4600b786596f0b17fd00106 (patch)
tree55ad39cbfd920747bd907a61438f19c12235f553 /src/mongo/db
parentb3bc4954c8f9044b92ccfbb4e872f87c69e39016 (diff)
downloadmongo-ec4a3883899f3ea9f4600b786596f0b17fd00106.tar.gz
SERVER-32375 Use readConcern local for config metadata operations
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/s/config/configsvr_add_shard_command.cpp5
-rw-r--r--src/mongo/db/s/config/configsvr_add_shard_to_zone_command.cpp5
-rw-r--r--src/mongo/db/s/config/configsvr_commit_chunk_migration_command.cpp4
-rw-r--r--src/mongo/db/s/config/configsvr_commit_move_primary_command.cpp5
-rw-r--r--src/mongo/db/s/config/configsvr_control_balancer_command.cpp6
-rw-r--r--src/mongo/db/s/config/configsvr_create_collection_command.cpp6
-rw-r--r--src/mongo/db/s/config/configsvr_create_database_command.cpp6
-rw-r--r--src/mongo/db/s/config/configsvr_drop_collection_command.cpp8
-rw-r--r--src/mongo/db/s/config/configsvr_drop_database_command.cpp8
-rw-r--r--src/mongo/db/s/config/configsvr_enable_sharding_command.cpp5
-rw-r--r--src/mongo/db/s/config/configsvr_merge_chunk_command.cpp5
-rw-r--r--src/mongo/db/s/config/configsvr_move_chunk_command.cpp6
-rw-r--r--src/mongo/db/s/config/configsvr_move_primary_command.cpp14
-rw-r--r--src/mongo/db/s/config/configsvr_remove_shard_command.cpp7
-rw-r--r--src/mongo/db/s/config/configsvr_remove_shard_from_zone_command.cpp5
-rw-r--r--src/mongo/db/s/config/configsvr_shard_collection_command.cpp7
-rw-r--r--src/mongo/db/s/config/configsvr_split_chunk_command.cpp5
-rw-r--r--src/mongo/db/s/config/configsvr_update_zone_key_range_command.cpp5
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager_remove_shard_test.cpp4
19 files changed, 104 insertions, 12 deletions
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 75fcba534a5..bf5ed552446 100644
--- a/src/mongo/db/s/config/configsvr_add_shard_command.cpp
+++ b/src/mongo/db/s/config/configsvr_add_shard_command.cpp
@@ -37,6 +37,7 @@
#include "mongo/db/commands.h"
#include "mongo/db/commands/feature_compatibility_version.h"
#include "mongo/db/namespace_string.h"
+#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/repl/repl_set_config.h"
#include "mongo/db/repl/replication_coordinator.h"
#include "mongo/db/s/config/sharding_catalog_manager.h"
@@ -101,6 +102,10 @@ public:
invariant(!opCtx->lockState()->isLocked());
Lock::SharedLock lk(opCtx->lockState(), FeatureCompatibilityVersion::fcvLock);
+ // Set the operation context read concern level to local for reads into the config database.
+ repl::ReadConcernArgs::get(opCtx) =
+ repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern);
+
auto swParsedRequest = AddShardRequest::parseFromConfigCommand(cmdObj);
uassertStatusOK(swParsedRequest.getStatus());
auto parsedRequest = std::move(swParsedRequest.getValue());
diff --git a/src/mongo/db/s/config/configsvr_add_shard_to_zone_command.cpp b/src/mongo/db/s/config/configsvr_add_shard_to_zone_command.cpp
index 726621d712f..5c50ee4ed73 100644
--- a/src/mongo/db/s/config/configsvr_add_shard_to_zone_command.cpp
+++ b/src/mongo/db/s/config/configsvr_add_shard_to_zone_command.cpp
@@ -35,6 +35,7 @@
#include "mongo/db/auth/privilege.h"
#include "mongo/db/commands.h"
#include "mongo/db/namespace_string.h"
+#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/s/config/sharding_catalog_manager.h"
#include "mongo/s/grid.h"
#include "mongo/s/request_types/add_shard_to_zone_request_type.h"
@@ -96,6 +97,10 @@ public:
"_configsvrAddShardToZone can only be run on config servers");
}
+ // Set the operation context read concern level to local for reads into the config database.
+ repl::ReadConcernArgs::get(opCtx) =
+ repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern);
+
auto parsedRequest = uassertStatusOK(AddShardToZoneRequest::parseFromConfigCommand(cmdObj));
uassertStatusOK(ShardingCatalogManager::get(opCtx)->addShardToZone(
diff --git a/src/mongo/db/s/config/configsvr_commit_chunk_migration_command.cpp b/src/mongo/db/s/config/configsvr_commit_chunk_migration_command.cpp
index c80f4bb02a3..6385c417d77 100644
--- a/src/mongo/db/s/config/configsvr_commit_chunk_migration_command.cpp
+++ b/src/mongo/db/s/config/configsvr_commit_chunk_migration_command.cpp
@@ -122,6 +122,10 @@ public:
const BSONObj& cmdObj,
BSONObjBuilder& result) override {
+ // Set the operation context read concern level to local for reads into the config database.
+ repl::ReadConcernArgs::get(opCtx) =
+ repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern);
+
const NamespaceString nss = NamespaceString(parseNs(dbName, cmdObj));
auto commitRequest =
diff --git a/src/mongo/db/s/config/configsvr_commit_move_primary_command.cpp b/src/mongo/db/s/config/configsvr_commit_move_primary_command.cpp
index a01327befca..a0502a83fb4 100644
--- a/src/mongo/db/s/config/configsvr_commit_move_primary_command.cpp
+++ b/src/mongo/db/s/config/configsvr_commit_move_primary_command.cpp
@@ -32,6 +32,7 @@
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/commands.h"
+#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/s/config/sharding_catalog_manager.h"
#include "mongo/s/request_types/move_primary_gen.h"
#include "mongo/util/log.h"
@@ -79,6 +80,10 @@ public:
"_configsvrCommitMovePrimary can only be run on config servers");
}
+ // Set the operation context read concern level to local for reads into the config database.
+ repl::ReadConcernArgs::get(opCtx) =
+ repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern);
+
uassert(ErrorCodes::InvalidOptions,
str::stream() << "commitMovePrimary must be called with majority writeConcern, got "
<< cmdObj,
diff --git a/src/mongo/db/s/config/configsvr_control_balancer_command.cpp b/src/mongo/db/s/config/configsvr_control_balancer_command.cpp
index dec9602587d..1576e3d8d27 100644
--- a/src/mongo/db/s/config/configsvr_control_balancer_command.cpp
+++ b/src/mongo/db/s/config/configsvr_control_balancer_command.cpp
@@ -33,6 +33,7 @@
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/auth/privilege.h"
#include "mongo/db/commands.h"
+#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/s/balancer/balancer.h"
#include "mongo/s/balancer_configuration.h"
#include "mongo/s/grid.h"
@@ -111,6 +112,11 @@ public:
private:
void _run(OperationContext* opCtx, BSONObjBuilder* result) override {
+
+ // Set the operation context read concern level to local for reads into the config database.
+ repl::ReadConcernArgs::get(opCtx) =
+ repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern);
+
uassertStatusOK(Grid::get(opCtx)->getBalancerConfiguration()->setBalancerMode(
opCtx, BalancerSettingsType::kOff));
Balancer::get(opCtx)->joinCurrentRound(opCtx);
diff --git a/src/mongo/db/s/config/configsvr_create_collection_command.cpp b/src/mongo/db/s/config/configsvr_create_collection_command.cpp
index f4f99fa1ab8..e6c0ffd4af1 100644
--- a/src/mongo/db/s/config/configsvr_create_collection_command.cpp
+++ b/src/mongo/db/s/config/configsvr_create_collection_command.cpp
@@ -39,6 +39,7 @@
#include "mongo/db/catalog/collection_options.h"
#include "mongo/db/commands.h"
#include "mongo/db/operation_context.h"
+#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/s/config/sharding_catalog_manager.h"
#include "mongo/s/grid.h"
#include "mongo/s/request_types/create_collection_gen.h"
@@ -68,6 +69,11 @@ public:
str::stream() << "createCollection must be called with majority writeConcern",
opCtx->getWriteConcern().wMode == WriteConcernOptions::kMajority);
+ // Set the operation context read concern level to local for reads into the config
+ // database.
+ repl::ReadConcernArgs::get(opCtx) =
+ repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern);
+
CollectionOptions options;
if (auto requestOptions = request().getOptions()) {
uassertStatusOK(options.parse(*requestOptions));
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 dfe3ee5b57e..7dd435812b1 100644
--- a/src/mongo/db/s/config/configsvr_create_database_command.cpp
+++ b/src/mongo/db/s/config/configsvr_create_database_command.cpp
@@ -39,6 +39,7 @@
#include "mongo/db/client.h"
#include "mongo/db/commands.h"
#include "mongo/db/operation_context.h"
+#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/s/config/sharding_catalog_manager.h"
#include "mongo/s/catalog/type_database.h"
#include "mongo/s/catalog_cache.h"
@@ -67,6 +68,11 @@ public:
"_configsvrCreateDatabase can only be run on config servers",
serverGlobalParams.clusterRole == ClusterRole::ConfigServer);
+ // Set the operation context read concern level to local for reads into the config
+ // database.
+ repl::ReadConcernArgs::get(opCtx) =
+ repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern);
+
auto dbname = request().getCommandParameter();
uassert(ErrorCodes::InvalidNamespace,
diff --git a/src/mongo/db/s/config/configsvr_drop_collection_command.cpp b/src/mongo/db/s/config/configsvr_drop_collection_command.cpp
index 1fce0832ca3..2e91223c164 100644
--- a/src/mongo/db/s/config/configsvr_drop_collection_command.cpp
+++ b/src/mongo/db/s/config/configsvr_drop_collection_command.cpp
@@ -97,6 +97,10 @@ public:
"_configsvrDropCollection can only be run on config servers",
serverGlobalParams.clusterRole == ClusterRole::ConfigServer);
+ // Set the operation context read concern level to local for reads into the config database.
+ repl::ReadConcernArgs::get(opCtx) =
+ repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern);
+
const NamespaceString nss(parseNs(dbname, cmdObj));
uassert(ErrorCodes::InvalidOptions,
@@ -120,7 +124,7 @@ public:
[opCtx, nss] { Grid::get(opCtx)->catalogCache()->invalidateShardedCollection(nss); });
auto collStatus =
- catalogClient->getCollection(opCtx, nss, repl::ReadConcernLevel::kLocalReadConcern);
+ catalogClient->getCollection(opCtx, nss, repl::ReadConcernArgs::get(opCtx).getLevel());
if (collStatus == ErrorCodes::NamespaceNotFound) {
// We checked the sharding catalog and found that this collection doesn't exist.
// This may be because it never existed, or because a drop command was sent
@@ -131,7 +135,7 @@ public:
// If the DB isn't in the sharding catalog either, consider the drop a success.
auto dbStatus = catalogClient->getDatabase(
- opCtx, nss.db().toString(), repl::ReadConcernLevel::kLocalReadConcern);
+ opCtx, nss.db().toString(), repl::ReadConcernArgs::get(opCtx).getLevel());
if (dbStatus == ErrorCodes::NamespaceNotFound) {
return true;
}
diff --git a/src/mongo/db/s/config/configsvr_drop_database_command.cpp b/src/mongo/db/s/config/configsvr_drop_database_command.cpp
index 9e8f2d092c7..cbd5d013755 100644
--- a/src/mongo/db/s/config/configsvr_drop_database_command.cpp
+++ b/src/mongo/db/s/config/configsvr_drop_database_command.cpp
@@ -93,6 +93,10 @@ public:
"_configsvrDropDatabase can only be run on config servers");
}
+ // Set the operation context read concern level to local for reads into the config database.
+ repl::ReadConcernArgs::get(opCtx) =
+ repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern);
+
const std::string dbname = parseNs("", cmdObj);
uassert(
@@ -115,7 +119,7 @@ public:
ON_BLOCK_EXIT([opCtx, dbname] { Grid::get(opCtx)->catalogCache()->purgeDatabase(dbname); });
auto dbInfo =
- catalogClient->getDatabase(opCtx, dbname, repl::ReadConcernLevel::kLocalReadConcern);
+ catalogClient->getDatabase(opCtx, dbname, repl::ReadConcernArgs::get(opCtx).getLevel());
// If the namespace isn't found, treat the drop as a success. In case the drop just happened
// and has not fully propagated, set the client's last optime to the system's last optime to
@@ -140,7 +144,7 @@ public:
// Drop the database's collections.
for (const auto& nss : catalogClient->getAllShardedCollectionsForDb(
- opCtx, dbname, repl::ReadConcernLevel::kLocalReadConcern)) {
+ opCtx, dbname, repl::ReadConcernArgs::get(opCtx).getLevel())) {
auto collDistLock = uassertStatusOK(catalogClient->getDistLockManager()->lock(
opCtx, nss.ns(), "dropCollection", DistLockManager::kDefaultLockTimeout));
uassertStatusOK(catalogManager->dropCollection(opCtx, nss));
diff --git a/src/mongo/db/s/config/configsvr_enable_sharding_command.cpp b/src/mongo/db/s/config/configsvr_enable_sharding_command.cpp
index 5401fd64a1e..198f108cc1d 100644
--- a/src/mongo/db/s/config/configsvr_enable_sharding_command.cpp
+++ b/src/mongo/db/s/config/configsvr_enable_sharding_command.cpp
@@ -39,6 +39,7 @@
#include "mongo/db/client.h"
#include "mongo/db/commands.h"
#include "mongo/db/operation_context.h"
+#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/s/config/sharding_catalog_manager.h"
#include "mongo/s/catalog/type_database.h"
#include "mongo/s/catalog_cache.h"
@@ -103,6 +104,10 @@ public:
"_configsvrEnableSharding can only be run on config servers");
}
+ // Set the operation context read concern level to local for reads into the config database.
+ repl::ReadConcernArgs::get(opCtx) =
+ repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern);
+
const std::string dbname = parseNs("", cmdObj);
uassert(
diff --git a/src/mongo/db/s/config/configsvr_merge_chunk_command.cpp b/src/mongo/db/s/config/configsvr_merge_chunk_command.cpp
index 6e5853fd14e..6c9fc840dad 100644
--- a/src/mongo/db/s/config/configsvr_merge_chunk_command.cpp
+++ b/src/mongo/db/s/config/configsvr_merge_chunk_command.cpp
@@ -36,6 +36,7 @@
#include "mongo/db/commands.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/operation_context.h"
+#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/s/config/sharding_catalog_manager.h"
#include "mongo/s/grid.h"
#include "mongo/s/request_types/merge_chunk_request_type.h"
@@ -107,6 +108,10 @@ public:
"_configsvrCommitChunkMerge can only be run on config servers");
}
+ // Set the operation context read concern level to local for reads into the config database.
+ repl::ReadConcernArgs::get(opCtx) =
+ repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern);
+
auto parsedRequest = uassertStatusOK(MergeChunkRequest::parseFromConfigCommand(cmdObj));
Status mergeChunkResult =
diff --git a/src/mongo/db/s/config/configsvr_move_chunk_command.cpp b/src/mongo/db/s/config/configsvr_move_chunk_command.cpp
index d2ad3c05399..88748293160 100644
--- a/src/mongo/db/s/config/configsvr_move_chunk_command.cpp
+++ b/src/mongo/db/s/config/configsvr_move_chunk_command.cpp
@@ -36,6 +36,7 @@
#include "mongo/db/auth/privilege.h"
#include "mongo/db/commands.h"
#include "mongo/db/namespace_string.h"
+#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/s/balancer/balancer.h"
#include "mongo/s/request_types/balance_chunk_request_type.h"
#include "mongo/util/log.h"
@@ -82,6 +83,11 @@ public:
const std::string& unusedDbName,
const BSONObj& cmdObj,
BSONObjBuilder& result) override {
+
+ // Set the operation context read concern level to local for reads into the config database.
+ repl::ReadConcernArgs::get(opCtx) =
+ repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern);
+
auto request = uassertStatusOK(BalanceChunkRequest::parseFromConfigCommand(cmdObj));
if (request.hasToShardId()) {
diff --git a/src/mongo/db/s/config/configsvr_move_primary_command.cpp b/src/mongo/db/s/config/configsvr_move_primary_command.cpp
index f84d976283c..82b49d344af 100644
--- a/src/mongo/db/s/config/configsvr_move_primary_command.cpp
+++ b/src/mongo/db/s/config/configsvr_move_primary_command.cpp
@@ -40,6 +40,7 @@
#include "mongo/db/commands.h"
#include "mongo/db/commands/feature_compatibility_version.h"
#include "mongo/db/operation_context.h"
+#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/repl/repl_client_info.h"
#include "mongo/db/s/config/sharding_catalog_manager.h"
#include "mongo/db/server_options.h"
@@ -112,6 +113,10 @@ public:
"_configsvrMovePrimary can only be run on config servers");
}
+ // Set the operation context read concern level to local for reads into the config database.
+ repl::ReadConcernArgs::get(opCtx) =
+ repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern);
+
auto movePrimaryRequest =
MovePrimary::parse(IDLParserErrorContext("ConfigSvrMovePrimary"), cmdObj);
const auto dbname = parseNs("", cmdObj);
@@ -146,9 +151,10 @@ public:
auto dbDistLock = uassertStatusOK(catalogClient->getDistLockManager()->lock(
opCtx, dbname, "movePrimary", DistLockManager::kDefaultLockTimeout));
- auto dbType = uassertStatusOK(catalogClient->getDatabase(
- opCtx, dbname, repl::ReadConcernLevel::kLocalReadConcern))
- .value;
+ auto dbType =
+ uassertStatusOK(catalogClient->getDatabase(
+ opCtx, dbname, repl::ReadConcernArgs::get(opCtx).getLevel()))
+ .value;
const auto fromShard = uassertStatusOK(shardRegistry->getShard(opCtx, dbType.getPrimary()));
@@ -207,7 +213,7 @@ public:
<< " to: " << toShard->toString();
const auto shardedColls = catalogClient->getAllShardedCollectionsForDb(
- opCtx, dbname, repl::ReadConcernLevel::kLocalReadConcern);
+ opCtx, dbname, repl::ReadConcernArgs::get(opCtx).getLevel());
// Record start in changelog
uassertStatusOK(catalogClient->logChange(
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 b77554f419d..883a830d833 100644
--- a/src/mongo/db/s/config/configsvr_remove_shard_command.cpp
+++ b/src/mongo/db/s/config/configsvr_remove_shard_command.cpp
@@ -39,6 +39,7 @@
#include "mongo/db/client.h"
#include "mongo/db/commands.h"
#include "mongo/db/operation_context.h"
+#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/s/config/sharding_catalog_manager.h"
#include "mongo/s/catalog/type_database.h"
#include "mongo/s/catalog_cache.h"
@@ -92,6 +93,10 @@ public:
"_configsvrRemoveShard can only be run on config servers",
serverGlobalParams.clusterRole == ClusterRole::ConfigServer);
+ // Set the operation context read concern level to local for reads into the config database.
+ repl::ReadConcernArgs::get(opCtx) =
+ repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern);
+
uassert(ErrorCodes::TypeMismatch,
str::stream() << "Field '" << cmdObj.firstElement().fieldName()
<< "' must be of type string",
@@ -154,7 +159,7 @@ public:
BSONObj(),
boost::none, // return all
nullptr,
- repl::ReadConcernLevel::kMajorityReadConcern);
+ repl::ReadConcernArgs::get(opCtx).getLevel());
uassertStatusOK(swChunks.getStatus());
const auto& chunks = swChunks.getValue();
diff --git a/src/mongo/db/s/config/configsvr_remove_shard_from_zone_command.cpp b/src/mongo/db/s/config/configsvr_remove_shard_from_zone_command.cpp
index b25854b9a14..d6ebac6787a 100644
--- a/src/mongo/db/s/config/configsvr_remove_shard_from_zone_command.cpp
+++ b/src/mongo/db/s/config/configsvr_remove_shard_from_zone_command.cpp
@@ -35,6 +35,7 @@
#include "mongo/db/auth/privilege.h"
#include "mongo/db/commands.h"
#include "mongo/db/namespace_string.h"
+#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/s/config/sharding_catalog_manager.h"
#include "mongo/s/grid.h"
#include "mongo/s/request_types/remove_shard_from_zone_request_type.h"
@@ -96,6 +97,10 @@ public:
"_configsvrRemoveShardFromZone can only be run on config servers");
}
+ // Set the operation context read concern level to local for reads into the config database.
+ repl::ReadConcernArgs::get(opCtx) =
+ repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern);
+
auto parsedRequest =
uassertStatusOK(RemoveShardFromZoneRequest::parseFromConfigCommand(cmdObj));
diff --git a/src/mongo/db/s/config/configsvr_shard_collection_command.cpp b/src/mongo/db/s/config/configsvr_shard_collection_command.cpp
index aa0baabf29d..9b0b1e52932 100644
--- a/src/mongo/db/s/config/configsvr_shard_collection_command.cpp
+++ b/src/mongo/db/s/config/configsvr_shard_collection_command.cpp
@@ -43,6 +43,7 @@
#include "mongo/db/index/index_descriptor.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/query/collation/collator_factory_interface.h"
+#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/repl/repl_client_info.h"
#include "mongo/db/repl/repl_set_config.h"
#include "mongo/db/repl/replication_coordinator.h"
@@ -727,6 +728,10 @@ public:
"_configsvrShardCollection can only be run on config servers",
serverGlobalParams.clusterRole == ClusterRole::ConfigServer);
+ // Set the operation context read concern level to local for reads into the config database.
+ repl::ReadConcernArgs::get(opCtx) =
+ repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern);
+
uassert(ErrorCodes::InvalidOptions,
str::stream() << "shardCollection must be called with majority writeConcern, got "
<< cmdObj,
@@ -756,7 +761,7 @@ public:
auto dbType =
uassertStatusOK(
Grid::get(opCtx)->catalogClient()->getDatabase(
- opCtx, nss.db().toString(), repl::ReadConcernLevel::kLocalReadConcern))
+ opCtx, nss.db().toString(), repl::ReadConcernArgs::get(opCtx).getLevel()))
.value;
uassert(ErrorCodes::IllegalOperation,
str::stream() << "sharding not enabled for db " << nss.db(),
diff --git a/src/mongo/db/s/config/configsvr_split_chunk_command.cpp b/src/mongo/db/s/config/configsvr_split_chunk_command.cpp
index fb2a8ab7893..6f5bd2dc10a 100644
--- a/src/mongo/db/s/config/configsvr_split_chunk_command.cpp
+++ b/src/mongo/db/s/config/configsvr_split_chunk_command.cpp
@@ -36,6 +36,7 @@
#include "mongo/db/commands.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/operation_context.h"
+#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/s/config/sharding_catalog_manager.h"
#include "mongo/s/grid.h"
#include "mongo/s/request_types/split_chunk_request_type.h"
@@ -105,6 +106,10 @@ public:
"_configsvrCommitChunkSplit can only be run on config servers");
}
+ // Set the operation context read concern level to local for reads into the config database.
+ repl::ReadConcernArgs::get(opCtx) =
+ repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern);
+
auto parsedRequest = uassertStatusOK(SplitChunkRequest::parseFromConfigCommand(cmdObj));
Status splitChunkResult =
diff --git a/src/mongo/db/s/config/configsvr_update_zone_key_range_command.cpp b/src/mongo/db/s/config/configsvr_update_zone_key_range_command.cpp
index 579e1518b83..96a42bb7cb9 100644
--- a/src/mongo/db/s/config/configsvr_update_zone_key_range_command.cpp
+++ b/src/mongo/db/s/config/configsvr_update_zone_key_range_command.cpp
@@ -35,6 +35,7 @@
#include "mongo/db/auth/privilege.h"
#include "mongo/db/commands.h"
#include "mongo/db/namespace_string.h"
+#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/s/config/sharding_catalog_manager.h"
#include "mongo/s/grid.h"
#include "mongo/s/request_types/update_zone_key_range_request_type.h"
@@ -98,6 +99,10 @@ public:
"_configsvrAssignKeyRangeToZone can only be run on config servers");
}
+ // Set the operation context read concern level to local for reads into the config database.
+ repl::ReadConcernArgs::get(opCtx) =
+ repl::ReadConcernArgs(repl::ReadConcernLevel::kLocalReadConcern);
+
auto parsedRequest =
uassertStatusOK(UpdateZoneKeyRangeRequest::parseFromConfigCommand(cmdObj));
diff --git a/src/mongo/db/s/config/sharding_catalog_manager_remove_shard_test.cpp b/src/mongo/db/s/config/sharding_catalog_manager_remove_shard_test.cpp
index 6def5ee6603..7c27e83a5a9 100644
--- a/src/mongo/db/s/config/sharding_catalog_manager_remove_shard_test.cpp
+++ b/src/mongo/db/s/config/sharding_catalog_manager_remove_shard_test.cpp
@@ -100,7 +100,7 @@ protected:
auto response = assertGet(shardRegistry()->getConfigShard()->exhaustiveFindOnConfig(
operationContext(),
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
- repl::ReadConcernLevel::kMajorityReadConcern,
+ repl::ReadConcernLevel::kLocalReadConcern,
ShardType::ConfigNS,
BSON(ShardType::name() << shardName),
BSONObj(),
@@ -313,7 +313,7 @@ TEST_F(RemoveShardTest, RemoveShardCompletion) {
auto response = assertGet(shardRegistry()->getConfigShard()->exhaustiveFindOnConfig(
operationContext(),
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
- repl::ReadConcernLevel::kMajorityReadConcern,
+ repl::ReadConcernLevel::kLocalReadConcern,
ShardType::ConfigNS,
BSON(ShardType::name() << shard1.getName()),
BSONObj(),