diff options
author | Romans Kasperovics <romans.kasperovics@mongodb.com> | 2023-05-16 08:26:12 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-05-16 09:20:40 +0000 |
commit | e9aea79d1d71e55fc40b43ba7d5894df8ab971c5 (patch) | |
tree | 383c167c7442557aff400f56eb57e2a4f7f97dd7 | |
parent | 31572586adb8aac04d930ca56887ca742bd2c048 (diff) | |
download | mongo-e9aea79d1d71e55fc40b43ba7d5894df8ab971c5.tar.gz |
SERVER-76903 Run multi-tenant change stream suites only on all-feature-flags variants
Additionally:
- remove the invariant that might be triggered by changing the FCV in tests
- remove serverless change stream feature flag dependency from change stream option validation
- remove serverless change stream feature flag dependency from run_aggregate.cpp
-rw-r--r-- | etc/evergreen.yml | 3 | ||||
-rw-r--r-- | etc/evergreen_yml_components/definitions.yml | 4 | ||||
-rw-r--r-- | src/mongo/db/change_stream_options_manager.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/change_stream_pre_image_util.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/change_stream_serverless_helpers.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/change_stream_serverless_helpers.h | 2 | ||||
-rw-r--r-- | src/mongo/db/change_streams_cluster_parameter.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/commands/run_aggregate.cpp | 7 | ||||
-rw-r--r-- | src/mongo/db/op_observer/op_observer_impl.cpp | 28 | ||||
-rw-r--r-- | src/mongo/db/repl/oplog.cpp | 24 |
10 files changed, 19 insertions, 63 deletions
diff --git a/etc/evergreen.yml b/etc/evergreen.yml index 18acc9b7927..a59ec017161 100644 --- a/etc/evergreen.yml +++ b/etc/evergreen.yml @@ -1200,6 +1200,7 @@ buildvariants: - name: .causally_consistent !.sharding - name: .change_streams - name: .change_stream_fuzzer + # TODO SERVER-57866: Remove the explicit mentions of change stream multitenant suites. - name: change_streams_multitenant_passthrough - name: change_streams_multitenant_sharded_collections_passthrough - name: .misc_js @@ -1852,6 +1853,7 @@ buildvariants: - name: .causally_consistent !.sharding - name: .change_streams - name: .change_stream_fuzzer + # TODO SERVER-57866: Remove the explicit mentions of change stream multitenant suites. - name: change_streams_multitenant_passthrough - name: change_streams_multitenant_sharded_collections_passthrough - name: cqf @@ -2091,6 +2093,7 @@ buildvariants: - name: cqf_parallel - name: .causally_consistent !.wo_snapshot - name: .change_streams + # TODO SERVER-57866: Remove the explicit mentions of change stream multitenant suites. - name: change_streams_multitenant_passthrough - name: change_streams_multitenant_sharded_collections_passthrough - name: disk_wiredtiger diff --git a/etc/evergreen_yml_components/definitions.yml b/etc/evergreen_yml_components/definitions.yml index cc62dc05f7a..9b305aa4bca 100644 --- a/etc/evergreen_yml_components/definitions.yml +++ b/etc/evergreen_yml_components/definitions.yml @@ -4934,14 +4934,14 @@ tasks: - <<: *task_template name: change_streams_multitenant_passthrough - tags: ["change_streams"] + tags: [] # TODO SERVER-57866: Add the "change_streams" tag here. commands: - func: "do setup" - func: "run tests" - <<: *task_template name: change_streams_multitenant_sharded_collections_passthrough - tags: ["change_streams"] + tags: [] # TODO SERVER-57866: Add the "change_streams" tag here. commands: - func: "do setup" - func: "run tests" diff --git a/src/mongo/db/change_stream_options_manager.cpp b/src/mongo/db/change_stream_options_manager.cpp index 37e82659886..9d3300e58b7 100644 --- a/src/mongo/db/change_stream_options_manager.cpp +++ b/src/mongo/db/change_stream_options_manager.cpp @@ -136,7 +136,7 @@ Status ChangeStreamOptionsParameter::validate(const BSONElement& newValueElement } }, [&](const std::int64_t& expireAfterSeconds) { - if (change_stream_serverless_helpers::isChangeCollectionsModeActive()) { + if (change_stream_serverless_helpers::isServerlessEnvironment()) { validateStatus = { ErrorCodes::CommandNotSupported, "The 'changeStreamOptions.preAndPostImages.expireAfterSeconds' is " diff --git a/src/mongo/db/change_stream_pre_image_util.cpp b/src/mongo/db/change_stream_pre_image_util.cpp index 56291553149..c66f32d8a96 100644 --- a/src/mongo/db/change_stream_pre_image_util.cpp +++ b/src/mongo/db/change_stream_pre_image_util.cpp @@ -57,11 +57,7 @@ boost::optional<std::int64_t> getExpireAfterSecondsFromChangeStreamOptions( boost::optional<Date_t> getPreImageExpirationTime(OperationContext* opCtx, Date_t currentTime) { // Non-serverless and serverless environments expire pre-images according to different logic and - // parameters. - // - // This method retrieves the 'expireAfterSeconds' for a single-tenant environment. Prohibit - // callers from using this in a serverless setting. - invariant(!change_stream_serverless_helpers::isChangeCollectionsModeActive()); + // parameters. This method retrieves the 'expireAfterSeconds' for a single-tenant environment. boost::optional<std::int64_t> expireAfterSeconds = boost::none; // Get the expiration time directly from the change stream manager. diff --git a/src/mongo/db/change_stream_serverless_helpers.cpp b/src/mongo/db/change_stream_serverless_helpers.cpp index f8406d07a99..b48bd36667d 100644 --- a/src/mongo/db/change_stream_serverless_helpers.cpp +++ b/src/mongo/db/change_stream_serverless_helpers.cpp @@ -74,10 +74,10 @@ bool canInitializeServices() { return false; } - return canRunInTargetEnvironment(); + return isServerlessEnvironment(); } -bool canRunInTargetEnvironment() { +bool isServerlessEnvironment() { // A change stream services are enabled only in the multitenant serverless settings. For the // sharded cluster, 'internalChangeStreamUseTenantIdForTesting' maybe provided for the testing // purposes until the support is available. diff --git a/src/mongo/db/change_stream_serverless_helpers.h b/src/mongo/db/change_stream_serverless_helpers.h index 9298603982f..5d088c65be2 100644 --- a/src/mongo/db/change_stream_serverless_helpers.h +++ b/src/mongo/db/change_stream_serverless_helpers.h @@ -60,7 +60,7 @@ bool canInitializeServices(); * Returns true if the target environment (replica-set or sharded-cluster) supports running change * stream in the serverless, false otherwise. */ -bool canRunInTargetEnvironment(); +bool isServerlessEnvironment(); /** * Returns an internal tenant id that will be used for testing purposes. This tenant id will not diff --git a/src/mongo/db/change_streams_cluster_parameter.cpp b/src/mongo/db/change_streams_cluster_parameter.cpp index f3636b6e41c..036a27fd631 100644 --- a/src/mongo/db/change_streams_cluster_parameter.cpp +++ b/src/mongo/db/change_streams_cluster_parameter.cpp @@ -49,7 +49,7 @@ Status validateChangeStreamsClusterParameter( return {ErrorCodes::IllegalOperation, "The 'changeStreams' parameter is unsupported in standalone."}; } - if (!change_stream_serverless_helpers::canRunInTargetEnvironment()) { + if (!change_stream_serverless_helpers::isServerlessEnvironment()) { return Status( ErrorCodes::CommandNotSupported, "The 'changeStreams' cluster-wide parameter is only available in serverless."); diff --git a/src/mongo/db/commands/run_aggregate.cpp b/src/mongo/db/commands/run_aggregate.cpp index 4a95b56eb13..a290ef56713 100644 --- a/src/mongo/db/commands/run_aggregate.cpp +++ b/src/mongo/db/commands/run_aggregate.cpp @@ -874,9 +874,8 @@ Status runAggregate(OperationContext* opCtx, nss = NamespaceString::kRsOplogNamespace; // In case of serverless the change stream will be opened on the change collection. - const bool changeCollectionsMode = - change_stream_serverless_helpers::isChangeCollectionsModeActive(); - if (changeCollectionsMode) { + const bool isServerless = change_stream_serverless_helpers::isServerlessEnvironment(); + if (isServerless) { const auto tenantId = change_stream_serverless_helpers::resolveTenantId(origNss.tenantId()); @@ -923,7 +922,7 @@ Status runAggregate(OperationContext* opCtx, registerTelemetry(); uassert(ErrorCodes::ChangeStreamNotEnabled, "Change streams must be enabled before being used", - !changeCollectionsMode || + !isServerless || change_stream_serverless_helpers::isChangeStreamEnabled(opCtx, *nss.tenantId())); } else if (nss.isCollectionlessAggregateNS() && pipelineInvolvedNamespaces.empty()) { diff --git a/src/mongo/db/op_observer/op_observer_impl.cpp b/src/mongo/db/op_observer/op_observer_impl.cpp index e3ed6a0159c..a4f14b9a6c2 100644 --- a/src/mongo/db/op_observer/op_observer_impl.cpp +++ b/src/mongo/db/op_observer/op_observer_impl.cpp @@ -380,30 +380,6 @@ void logGlobalIndexDDLOperation(OperationContext* opCtx, onWriteOpCompleted(opCtx, {stmtId}, sessionTxnRecord); } -/** - * See isTenantChangeStreamEnabled() in oplog.cpp. - */ -bool isTenantChangeStreamEnabled(OperationContext* opCtx, boost::optional<TenantId> tenantId) { - const auto& settings = repl::ReplicationCoordinator::get(opCtx)->getSettings(); - if (!settings.isServerless()) { - return false; - } - - if (!change_stream_serverless_helpers::isChangeCollectionsModeActive()) { - return false; - } - - if (!tenantId) { - return false; - } - - if (!change_stream_serverless_helpers::isChangeStreamEnabled(opCtx, tenantId.get())) { - return false; - } - - return true; -} - } // namespace OpObserverImpl::OpObserverImpl(std::unique_ptr<OplogWriter> oplogWriter) @@ -629,7 +605,9 @@ std::vector<repl::OpTime> _logInsertOps(OperationContext* opCtx, // UUID and optional donor timeline metadata. if (const auto& recipientInfo = repl::tenantMigrationInfo(opCtx)) { oplogEntryTemplate->setFromTenantMigration(recipientInfo->uuid); - if (isTenantChangeStreamEnabled(opCtx, oplogEntryTemplate->getTid()) && + if (oplogEntryTemplate->getTid() && + change_stream_serverless_helpers::isChangeStreamEnabled( + opCtx, *oplogEntryTemplate->getTid()) && recipientInfo->donorOplogEntryData) { oplogEntryTemplate->setDonorOpTime(recipientInfo->donorOplogEntryData->donorOpTime); oplogEntryTemplate->setDonorApplyOpsIndex( diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp index 908e64d878c..c6448ea3f62 100644 --- a/src/mongo/db/repl/oplog.cpp +++ b/src/mongo/db/repl/oplog.cpp @@ -174,27 +174,6 @@ StringData getInvalidatingReason(const OplogApplication::Mode mode, const bool i return ""_sd; } -bool isTenantChangeStreamEnabled(OperationContext* opCtx, boost::optional<TenantId> tenantId) { - const auto& settings = ReplicationCoordinator::get(opCtx)->getSettings(); - if (!settings.isServerless()) { - return false; - } - - if (!change_stream_serverless_helpers::isChangeCollectionsModeActive()) { - return false; - } - - if (!tenantId) { - return false; - } - - if (!change_stream_serverless_helpers::isChangeStreamEnabled(opCtx, tenantId.get())) { - return false; - } - - return true; -} - Status insertDocumentsForOplog(OperationContext* opCtx, const CollectionPtr& oplogCollection, std::vector<Record>* records, @@ -518,7 +497,8 @@ OpTime logOp(OperationContext* opCtx, MutableOplogEntry* oplogEntry) { // UUID and optional donor timeline metadata. if (const auto& recipientInfo = tenantMigrationInfo(opCtx)) { oplogEntry->setFromTenantMigration(recipientInfo->uuid); - if (isTenantChangeStreamEnabled(opCtx, oplogEntry->getTid()) && + if (oplogEntry->getTid() && + change_stream_serverless_helpers::isChangeStreamEnabled(opCtx, *oplogEntry->getTid()) && recipientInfo->donorOplogEntryData) { oplogEntry->setDonorOpTime(recipientInfo->donorOplogEntryData->donorOpTime); oplogEntry->setDonorApplyOpsIndex(recipientInfo->donorOplogEntryData->applyOpsIndex); |