diff options
Diffstat (limited to 'src/mongo/db/commands/run_aggregate.cpp')
-rw-r--r-- | src/mongo/db/commands/run_aggregate.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/mongo/db/commands/run_aggregate.cpp b/src/mongo/db/commands/run_aggregate.cpp index c2f2701cd42..e08e6b09e30 100644 --- a/src/mongo/db/commands/run_aggregate.cpp +++ b/src/mongo/db/commands/run_aggregate.cpp @@ -795,19 +795,15 @@ Status runAggregate(OperationContext* opCtx, nss = NamespaceString::kRsOplogNamespace; // In case of serverless the change stream will be opened on the change collection. - if (change_stream_serverless_helpers::isChangeCollectionsModeActive()) { + const bool changeCollectionsMode = + change_stream_serverless_helpers::isChangeCollectionsModeActive(); + if (changeCollectionsMode) { const auto tenantId = change_stream_serverless_helpers::resolveTenantId(origNss.tenantId()); uassert(ErrorCodes::BadValue, "Change streams cannot be used without tenant id", tenantId); - - uassert(ErrorCodes::ChangeStreamNotEnabled, - "Change streams must be enabled before being used.", - change_stream_serverless_helpers::isChangeStreamEnabled(opCtx, *tenantId)); - - nss = NamespaceString::makeChangeCollectionNSS(tenantId); } @@ -846,6 +842,11 @@ Status runAggregate(OperationContext* opCtx, // Obtain collection locks on the execution namespace; that is, the oplog. initContext(auto_get_collection::ViewMode::kViewsForbidden); registerTelemetry(); + uassert(ErrorCodes::ChangeStreamNotEnabled, + "Change streams must be enabled before being used", + !changeCollectionsMode || + change_stream_serverless_helpers::isChangeStreamEnabled(opCtx, + *nss.tenantId())); } else if (nss.isCollectionlessAggregateNS() && pipelineInvolvedNamespaces.empty()) { uassert(4928901, str::stream() << AggregateCommandRequest::kCollectionUUIDFieldName |