summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/create_collection_coordinator.cpp
diff options
context:
space:
mode:
authorTommaso Tocci <tommaso.tocci@mongodb.com>2022-02-28 13:44:53 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-02-28 14:17:00 +0000
commit891c15831552cea487545c0b16944a7a195d6871 (patch)
treec10d83decef127c4e5dcaf3b004d162775c58372 /src/mongo/db/s/create_collection_coordinator.cpp
parent0544506460a4ff21be5a1d4708e38ecbf8338f88 (diff)
downloadmongo-891c15831552cea487545c0b16944a7a195d6871.tar.gz
SERVER-60926 Make enableSharding command optional
Diffstat (limited to 'src/mongo/db/s/create_collection_coordinator.cpp')
-rw-r--r--src/mongo/db/s/create_collection_coordinator.cpp39
1 files changed, 22 insertions, 17 deletions
diff --git a/src/mongo/db/s/create_collection_coordinator.cpp b/src/mongo/db/s/create_collection_coordinator.cpp
index 4016982d6c1..72766e99945 100644
--- a/src/mongo/db/s/create_collection_coordinator.cpp
+++ b/src/mongo/db/s/create_collection_coordinator.cpp
@@ -57,6 +57,7 @@
#include "mongo/s/cluster_commands_helpers.h"
#include "mongo/s/cluster_write.h"
#include "mongo/s/grid.h"
+#include "mongo/s/sharding_feature_flags_gen.h"
namespace mongo {
namespace {
@@ -630,25 +631,29 @@ ExecutorFuture<void> CreateCollectionCoordinator::_runImpl(
void CreateCollectionCoordinator::_checkCommandArguments(OperationContext* opCtx) {
LOGV2_DEBUG(5277902, 2, "Create collection _checkCommandArguments", "namespace"_attr = nss());
- const auto dbEnabledForSharding = [&, this] {
- // The modification of the 'sharded' flag for the db does not imply a database version
- // change so we can't use the DatabaseShardingState to look it up. Instead we will do a
- // first attempt through the catalog cache and if it is unset we will attempt another time
- // after a forced catalog cache refresh.
- auto catalogCache = Grid::get(opCtx)->catalogCache();
-
- auto dbInfo = uassertStatusOK(catalogCache->getDatabase(opCtx, nss().db()));
- if (!dbInfo.shardingEnabled()) {
- sharding_ddl_util::linearizeCSRSReads(opCtx);
- dbInfo = uassertStatusOK(catalogCache->getDatabaseWithRefresh(opCtx, nss().db()));
- }
+ if (!feature_flags::gEnableShardingOptional.isEnabled(
+ serverGlobalParams.featureCompatibility)) {
- return dbInfo.shardingEnabled();
- }();
+ const auto dbEnabledForSharding = [&, this] {
+ // The modification of the 'sharded' flag for the db does not imply a database version
+ // change so we can't use the DatabaseShardingState to look it up. Instead we will do a
+ // first attempt through the catalog cache and if it is unset we will attempt another
+ // time after a forced catalog cache refresh.
+ auto catalogCache = Grid::get(opCtx)->catalogCache();
- uassert(ErrorCodes::IllegalOperation,
- str::stream() << "sharding not enabled for db " << nss().db(),
- dbEnabledForSharding);
+ auto dbInfo = uassertStatusOK(catalogCache->getDatabase(opCtx, nss().db()));
+ if (!dbInfo.shardingEnabled()) {
+ sharding_ddl_util::linearizeCSRSReads(opCtx);
+ dbInfo = uassertStatusOK(catalogCache->getDatabaseWithRefresh(opCtx, nss().db()));
+ }
+
+ return dbInfo.shardingEnabled();
+ }();
+
+ uassert(ErrorCodes::IllegalOperation,
+ str::stream() << "sharding not enabled for db " << nss().db(),
+ dbEnabledForSharding);
+ }
uassert(ErrorCodes::InvalidNamespace,
str::stream() << "Namespace too long. Namespace: " << nss()