From 62ea49cf4617b71cbc03c0058ea477b0e86a8569 Mon Sep 17 00:00:00 2001 From: Paolo Polato Date: Fri, 16 Sep 2022 14:42:35 +0000 Subject: SERVER-62356 Fix multiversion suites --- src/mongo/db/s/create_collection_coordinator.cpp | 37 ++++++++++++++-------- .../db/s/shardsvr_create_collection_command.cpp | 3 +- src/mongo/s/sharding_feature_flags.idl | 5 +++ 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/mongo/db/s/create_collection_coordinator.cpp b/src/mongo/db/s/create_collection_coordinator.cpp index ff58d129036..343b9a885e5 100644 --- a/src/mongo/db/s/create_collection_coordinator.cpp +++ b/src/mongo/db/s/create_collection_coordinator.cpp @@ -418,19 +418,23 @@ ExecutorFuture CreateCollectionCoordinator::_runImpl( } } }) - .then(_executePhase(Phase::kTranslateRequest, - [this, anchor = shared_from_this()] { - auto opCtxHolder = cc().makeOperationContext(); - auto* opCtx = opCtxHolder.get(); - getForwardableOpMetadata().setOn(opCtx); - _logStartCreateCollection(opCtx); - - // Enter the critical sections before patching the user request to - // avoid data races with concurrenct creation of unsharded - // collections referencing the same namespace(s). - _acquireCriticalSections(opCtx); - _doc.setTranslatedRequestParams(_translateRequestParameters(opCtx)); - })) + .then([this, anchor = shared_from_this()] { + if (_timeseriesNssResolvedByCommandHandler()) { + return; + } + _executePhase(Phase::kTranslateRequest, [this, anchor = shared_from_this()] { + auto opCtxHolder = cc().makeOperationContext(); + auto* opCtx = opCtxHolder.get(); + getForwardableOpMetadata().setOn(opCtx); + _logStartCreateCollection(opCtx); + + // Enter the critical sections before patching the user request to + // avoid data races with concurrenct creation of unsharded + // collections referencing the same namespace(s). + _acquireCriticalSections(opCtx); + _doc.setTranslatedRequestParams(_translateRequestParameters(opCtx)); + })(); + }) .then(_executePhase( Phase::kCommit, [this, executor = executor, token, anchor = shared_from_this()] { @@ -451,6 +455,13 @@ ExecutorFuture CreateCollectionCoordinator::_runImpl( opCtx, getCurrentSession(), **executor); } + if (_timeseriesNssResolvedByCommandHandler()) { + // execute the logic of the kTranslateRequest phase now. + _logStartCreateCollection(opCtx); + _acquireCriticalSections(opCtx); + _doc.setTranslatedRequestParams(_translateRequestParameters(opCtx)); + } + // Check if the collection was already sharded by a past request if (auto createCollectionResponseOpt = sharding_ddl_util::checkIfCollectionAlreadySharded( diff --git a/src/mongo/db/s/shardsvr_create_collection_command.cpp b/src/mongo/db/s/shardsvr_create_collection_command.cpp index 3155963cc52..29453c185c8 100644 --- a/src/mongo/db/s/shardsvr_create_collection_command.cpp +++ b/src/mongo/db/s/shardsvr_create_collection_command.cpp @@ -145,10 +145,11 @@ public: request().getShardKey()); const auto createCollectionCoordinator = [&] { + FixedFCVRegion fcvRegion(opCtx); auto nssToForward = ns(); auto requestToForward = request().getCreateCollectionRequest(); auto coordinatorType = DDLCoordinatorTypeEnum::kCreateCollection; - if (!feature_flags::gImplicitDDLTimeseriesNssTranslation.isEnabled( + if (!feature_flags::gCreateCollectionCoordinatorV3.isEnabled( serverGlobalParams.featureCompatibility)) { translateToTimeseriesCollection(opCtx, &nssToForward, &requestToForward); coordinatorType = DDLCoordinatorTypeEnum::kCreateCollectionPre61Compatible; diff --git a/src/mongo/s/sharding_feature_flags.idl b/src/mongo/s/sharding_feature_flags.idl index dad24f5e69e..f47bc345d7a 100644 --- a/src/mongo/s/sharding_feature_flags.idl +++ b/src/mongo/s/sharding_feature_flags.idl @@ -60,6 +60,11 @@ feature_flags: cpp_varname: feature_flags::gCollModCoordinatorV3 default: true version: 6.1 + featureFlagCreateCollectionCoordinatorV3: + description: "Feature for enabling new createCollection coordinator v3" + cpp_varname: feature_flags::gCreateCollectionCoordinatorV3 + default: true + version: 6.2 featureFlagHistoricalPlacementShardingCatalog: description: "Feature flag for enabling the storage and access to historical placement data at shards granularity through the Sharding Catalog" cpp_varname: feature_flags::gHistoricalPlacementShardingCatalog -- cgit v1.2.1