diff options
-rw-r--r-- | src/mongo/db/commands/list_collections.cpp | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/src/mongo/db/commands/list_collections.cpp b/src/mongo/db/commands/list_collections.cpp index f78cfda6308..39bb826fd79 100644 --- a/src/mongo/db/commands/list_collections.cpp +++ b/src/mongo/db/commands/list_collections.cpp @@ -167,9 +167,7 @@ BSONObj buildViewBson(const ViewDefinition& view, bool nameOnly) { return b.obj(); } -BSONObj buildTimeseriesBson(OperationContext* opCtx, - const CollectionPtr& collection, - bool nameOnly) { +BSONObj buildTimeseriesBson(const CollectionPtr& collection, bool nameOnly) { invariant(collection); BSONObjBuilder builder; @@ -377,8 +375,7 @@ public: if (auto bucketsCollection = CollectionCatalog::get(opCtx) ->lookupCollectionByNamespace( opCtx, view->viewOn())) { - return buildTimeseriesBson( - opCtx, bucketsCollection, nameOnly); + return buildTimeseriesBson(bucketsCollection, nameOnly); } else { // The buckets collection does not exist, so the time-series // view will be appended when we iterate through the view @@ -397,21 +394,22 @@ public: } else { auto perCollectionWork = [&](const CollectionPtr& collection) { if (collection && collection->getTimeseriesOptions() && - !collection->ns().isDropPendingNamespace() && - catalog->lookupViewWithoutValidatingDurable( - opCtx, collection->ns().getTimeseriesViewNamespace()) && - (!authorizedCollections || - as->isAuthorizedForAnyActionOnResource( - ResourcePattern::forExactNamespace( - collection->ns().getTimeseriesViewNamespace())))) { - // The time-series view for this buckets namespace exists, so add it - // here while we have the collection options. - _addWorkingSetMember( - opCtx, - buildTimeseriesBson(opCtx, collection, nameOnly), - matcher.get(), - ws.get(), - root.get()); + !collection->ns().isDropPendingNamespace()) { + auto viewNss = collection->ns().getTimeseriesViewNamespace(); + auto view = + catalog->lookupViewWithoutValidatingDurable(opCtx, viewNss); + if (view && view->timeseries() && + (!authorizedCollections || + as->isAuthorizedForAnyActionOnResource( + ResourcePattern::forExactNamespace(viewNss)))) { + // The time-series view for this buckets namespace exists, so + // add it here while we have the collection options. + _addWorkingSetMember(opCtx, + buildTimeseriesBson(collection, nameOnly), + matcher.get(), + ws.get(), + root.get()); + } } if (authorizedCollections && |