summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands
diff options
context:
space:
mode:
authorDan Larkin-York <dan.larkin-york@mongodb.com>2022-02-26 13:50:02 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-02-26 14:34:46 +0000
commitcd92f1325982f82314e0cbb08ced8d254198a7b2 (patch)
tree5539b750af2e6ed189698edbe994d3f3b64bf194 /src/mongo/db/commands
parentfcad5cd7a9267980fefda51b1e4a3db0a12000ec (diff)
downloadmongo-cd92f1325982f82314e0cbb08ced8d254198a7b2.tar.gz
SERVER-57250 Merge ViewCatalog into CollectionCatalog
Diffstat (limited to 'src/mongo/db/commands')
-rw-r--r--src/mongo/db/commands/SConscript3
-rw-r--r--src/mongo/db/commands/compact.cpp1
-rw-r--r--src/mongo/db/commands/create_indexes.cpp7
-rw-r--r--src/mongo/db/commands/drop_indexes.cpp4
-rw-r--r--src/mongo/db/commands/fle2_compact.cpp4
-rw-r--r--src/mongo/db/commands/list_collections.cpp15
-rw-r--r--src/mongo/db/commands/run_aggregate.cpp90
-rw-r--r--src/mongo/db/commands/set_feature_compatibility_version_command.cpp1
-rw-r--r--src/mongo/db/commands/validate_db_metadata_cmd.cpp17
-rw-r--r--src/mongo/db/commands/write_commands.cpp2
10 files changed, 59 insertions, 85 deletions
diff --git a/src/mongo/db/commands/SConscript b/src/mongo/db/commands/SConscript
index 6e17b42669a..98c4b4c3a9e 100644
--- a/src/mongo/db/commands/SConscript
+++ b/src/mongo/db/commands/SConscript
@@ -233,7 +233,9 @@ env.Library(
],
LIBDEPS_PRIVATE=[
'$BUILD_DIR/mongo/crypto/encrypted_field_config',
+ '$BUILD_DIR/mongo/db/auth/auth',
'$BUILD_DIR/mongo/db/catalog/catalog_helpers',
+ '$BUILD_DIR/mongo/db/catalog/collection_catalog',
'$BUILD_DIR/mongo/db/catalog_raii',
'$BUILD_DIR/mongo/db/commands',
]
@@ -407,6 +409,7 @@ env.Library(
'$BUILD_DIR/mongo/db/timeseries/timeseries_conversion_util',
'$BUILD_DIR/mongo/db/timeseries/timeseries_stats',
'$BUILD_DIR/mongo/db/transaction',
+ '$BUILD_DIR/mongo/db/views/view_catalog_helpers',
'$BUILD_DIR/mongo/db/views/views_mongod',
'$BUILD_DIR/mongo/executor/async_request_executor',
'$BUILD_DIR/mongo/idl/feature_flag',
diff --git a/src/mongo/db/commands/compact.cpp b/src/mongo/db/commands/compact.cpp
index ca5e15affa9..6aa009ea216 100644
--- a/src/mongo/db/commands/compact.cpp
+++ b/src/mongo/db/commands/compact.cpp
@@ -41,7 +41,6 @@
#include "mongo/db/curop.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/repl/replication_coordinator.h"
-#include "mongo/db/views/view_catalog.h"
namespace mongo {
diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp
index 92c3efb2bbf..66d463e220f 100644
--- a/src/mongo/db/commands/create_indexes.cpp
+++ b/src/mongo/db/commands/create_indexes.cpp
@@ -39,6 +39,7 @@
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/catalog/clustered_collection_util.h"
#include "mongo/db/catalog/collection.h"
+#include "mongo/db/catalog/collection_catalog.h"
#include "mongo/db/catalog/collection_uuid_mismatch.h"
#include "mongo/db/catalog/create_collection.h"
#include "mongo/db/catalog/database.h"
@@ -66,7 +67,6 @@
#include "mongo/db/timeseries/catalog_helper.h"
#include "mongo/db/timeseries/timeseries_commands_conversion_helper.h"
#include "mongo/db/timeseries/timeseries_index_schema_conversion_functions.h"
-#include "mongo/db/views/view_catalog.h"
#include "mongo/idl/command_generic_argument.h"
#include "mongo/logv2/log.h"
#include "mongo/platform/compiler.h"
@@ -379,12 +379,9 @@ CreateIndexesReply runCreateIndexesOnNewCollection(
bool createCollImplicitly) {
WriteUnitOfWork wunit(opCtx);
- const TenantDatabaseName tenantDbName(boost::none, ns.db());
- auto databaseHolder = DatabaseHolder::get(opCtx);
- auto db = databaseHolder->getDb(opCtx, tenantDbName);
uassert(ErrorCodes::CommandNotSupportedOnView,
"Cannot create indexes on a view",
- !db || !ViewCatalog::get(opCtx)->lookup(opCtx, ns));
+ !CollectionCatalog::get(opCtx)->lookupView(opCtx, ns));
if (createCollImplicitly) {
for (const auto& spec : specs) {
diff --git a/src/mongo/db/commands/drop_indexes.cpp b/src/mongo/db/commands/drop_indexes.cpp
index 9dd71eeefb0..3f60b169975 100644
--- a/src/mongo/db/commands/drop_indexes.cpp
+++ b/src/mongo/db/commands/drop_indexes.cpp
@@ -36,6 +36,7 @@
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/catalog/collection.h"
+#include "mongo/db/catalog/collection_catalog.h"
#include "mongo/db/catalog/database.h"
#include "mongo/db/catalog/drop_indexes.h"
#include "mongo/db/catalog/index_catalog.h"
@@ -54,7 +55,6 @@
#include "mongo/db/timeseries/catalog_helper.h"
#include "mongo/db/timeseries/timeseries_commands_conversion_helper.h"
#include "mongo/db/vector_clock.h"
-#include "mongo/db/views/view_catalog.h"
#include "mongo/logv2/log.h"
#include "mongo/util/exit_code.h"
#include "mongo/util/quick_exit.h"
@@ -161,7 +161,7 @@ public:
AutoGetCollection autoColl(opCtx, toReIndexNss, MODE_X);
if (!autoColl) {
- if (ViewCatalog::get(opCtx)->lookup(opCtx, toReIndexNss))
+ if (CollectionCatalog::get(opCtx)->lookupView(opCtx, toReIndexNss))
uasserted(ErrorCodes::CommandNotSupportedOnView, "can't re-index a view");
else
uasserted(ErrorCodes::NamespaceNotFound, "collection does not exist");
diff --git a/src/mongo/db/commands/fle2_compact.cpp b/src/mongo/db/commands/fle2_compact.cpp
index 017b5840407..7588cbc6735 100644
--- a/src/mongo/db/commands/fle2_compact.cpp
+++ b/src/mongo/db/commands/fle2_compact.cpp
@@ -35,10 +35,10 @@
#include "mongo/crypto/encryption_fields_gen.h"
#include "mongo/db/auth/authorization_session.h"
+#include "mongo/db/catalog/collection_catalog.h"
#include "mongo/db/catalog/rename_collection.h"
#include "mongo/db/catalog_raii.h"
#include "mongo/db/commands.h"
-#include "mongo/db/views/view_catalog.h"
#include "mongo/logv2/log.h"
namespace mongo {
@@ -149,7 +149,7 @@ StatusWith<CompactStats> compactEncryptedCompactionCollection(
// Check the data collection exists and is not a view
auto edc = catalog->lookupCollectionByNamespace(opCtx, edcNss);
if (!edc) {
- if (ViewCatalog::get(opCtx)->lookup(opCtx, edcNss)) {
+ if (catalog->lookupView(opCtx, edcNss)) {
return Status(ErrorCodes::CommandNotSupportedOnView,
"cannot compact structured encryption data on a view");
}
diff --git a/src/mongo/db/commands/list_collections.cpp b/src/mongo/db/commands/list_collections.cpp
index 741e19ba454..3c5fa674aa9 100644
--- a/src/mongo/db/commands/list_collections.cpp
+++ b/src/mongo/db/commands/list_collections.cpp
@@ -41,6 +41,7 @@
#include "mongo/bson/util/bson_extract.h"
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/catalog/collection.h"
+#include "mongo/db/catalog/collection_catalog.h"
#include "mongo/db/catalog/collection_catalog_helper.h"
#include "mongo/db/catalog/database.h"
#include "mongo/db/catalog/database_holder.h"
@@ -65,7 +66,6 @@
#include "mongo/db/storage/storage_engine.h"
#include "mongo/db/storage/storage_options.h"
#include "mongo/db/timeseries/timeseries_constants.h"
-#include "mongo/db/views/view_catalog.h"
#include "mongo/logv2/log.h"
namespace mongo {
@@ -332,7 +332,7 @@ public:
// Acquire only the global lock and set up a consistent in-memory catalog and
// storage snapshot.
AutoGetDbForReadMaybeLockFree lockFreeReadBlock(opCtx, dbName);
- auto viewCatalog = DatabaseHolder::get(opCtx)->getViewCatalog(opCtx, tenantDbName);
+ auto catalog = CollectionCatalog::get(opCtx);
CurOpFailpointHelpers::waitWhileFailPointEnabled(&hangBeforeListCollections,
opCtx,
@@ -343,8 +343,8 @@ public:
auto ws = std::make_unique<WorkingSet>();
auto root = std::make_unique<QueuedDataStage>(expCtx.get(), ws.get());
- // If the ViewCatalog pointer is valid, then the database exists.
- if (viewCatalog) {
+ if (DatabaseHolder::get(opCtx)->dbExists(opCtx,
+ TenantDatabaseName(boost::none, dbName))) {
if (auto collNames = _getExactNameMatches(matcher.get())) {
for (auto&& collName : *collNames) {
auto nss = NamespaceString(dbName, collName);
@@ -372,8 +372,7 @@ public:
opCtx, collection, includePendingDrops, nameOnly);
}
- auto view =
- viewCatalog->lookupWithoutValidatingDurableViews(opCtx, nss);
+ auto view = catalog->lookupViewWithoutValidatingDurable(opCtx, nss);
if (view && view->timeseries()) {
if (auto bucketsCollection = CollectionCatalog::get(opCtx)
->lookupCollectionByNamespace(
@@ -399,7 +398,7 @@ public:
auto perCollectionWork = [&](const CollectionPtr& collection) {
if (collection && collection->getTimeseriesOptions() &&
!collection->ns().isDropPendingNamespace() &&
- viewCatalog->lookupWithoutValidatingDurableViews(
+ catalog->lookupViewWithoutValidatingDurable(
opCtx, collection->ns().getTimeseriesViewNamespace()) &&
(!authorizedCollections ||
as->isAuthorizedForAnyActionOnResource(
@@ -454,7 +453,7 @@ public:
ListCollectionsFilter::makeTypeCollectionFilter());
if (!skipViews) {
- viewCatalog->iterate(dbName, [&](const ViewDefinition& view) {
+ catalog->iterateViews(opCtx, dbName, [&](const ViewDefinition& view) {
if (authorizedCollections &&
!as->isAuthorizedForAnyActionOnResource(
ResourcePattern::forExactNamespace(view.name()))) {
diff --git a/src/mongo/db/commands/run_aggregate.cpp b/src/mongo/db/commands/run_aggregate.cpp
index eda074f1924..fb650d38acf 100644
--- a/src/mongo/db/commands/run_aggregate.cpp
+++ b/src/mongo/db/commands/run_aggregate.cpp
@@ -81,7 +81,7 @@
#include "mongo/db/stats/resource_consumption_metrics.h"
#include "mongo/db/storage/storage_options.h"
#include "mongo/db/views/view.h"
-#include "mongo/db/views/view_catalog.h"
+#include "mongo/db/views/view_catalog_helpers.h"
#include "mongo/logv2/log.h"
#include "mongo/util/scopeguard.h"
#include "mongo/util/string_map.h"
@@ -291,13 +291,12 @@ StatusWith<StringMap<ExpressionContext::ResolvedNamespace>> resolveInvolvedNames
return {StringMap<ExpressionContext::ResolvedNamespace>()};
}
- // Acquire a single const view of the database's ViewCatalog (if it exists) and use it for all
- // view definition resolutions that follow. This prevents the view definitions cached in
- // 'resolvedNamespaces' from changing relative to those in the acquired ViewCatalog. The
- // resolution of the view definitions below might lead into an endless cycle if any are allowed
- // to change.
- const TenantDatabaseName tenantDbName(boost::none, request.getNamespace().db());
- auto viewCatalog = DatabaseHolder::get(opCtx)->getViewCatalog(opCtx, tenantDbName);
+ // Acquire a single const view of the CollectionCatalog and use it for all view and collection
+ // lookups and view definition resolutions that follow. This prevents the view definitions
+ // cached in 'resolvedNamespaces' from changing relative to those in the acquired ViewCatalog.
+ // The resolution of the view definitions below might lead into an endless cycle if any are
+ // allowed to change.
+ auto catalog = CollectionCatalog::get(opCtx);
std::deque<NamespaceString> involvedNamespacesQueue(pipelineInvolvedNamespaces.begin(),
pipelineInvolvedNamespaces.end());
@@ -312,9 +311,8 @@ StatusWith<StringMap<ExpressionContext::ResolvedNamespace>> resolveInvolvedNames
}
// If 'ns' refers to a view namespace, then we resolve its definition.
- auto resolveViewDefinition = [&](const NamespaceString& ns,
- std::shared_ptr<const ViewCatalog> vcp) -> Status {
- auto resolvedView = vcp->resolveView(opCtx, ns, boost::none);
+ auto resolveViewDefinition = [&](const NamespaceString& ns) -> Status {
+ auto resolvedView = view_catalog_helpers::resolveView(opCtx, catalog, ns, boost::none);
if (!resolvedView.isOK()) {
return resolvedView.getStatus().withContext(
str::stream() << "Failed to resolve view '" << involvedNs.ns());
@@ -322,7 +320,7 @@ StatusWith<StringMap<ExpressionContext::ResolvedNamespace>> resolveInvolvedNames
auto&& underlyingNs = resolvedView.getValue().getNamespace();
// Attempt to acquire UUID of the underlying collection using lock free method.
- auto uuid = CollectionCatalog::get(opCtx)->lookupUUIDByNSS(opCtx, underlyingNs);
+ auto uuid = catalog->lookupUUIDByNSS(opCtx, underlyingNs);
resolvedNamespaces[ns.coll()] = {
underlyingNs, resolvedView.getValue().getPipeline(), uuid};
@@ -348,14 +346,7 @@ StatusWith<StringMap<ExpressionContext::ResolvedNamespace>> resolveInvolvedNames
// require a lookup stage involving a view on the 'local' database.
// If the involved namespace is 'local.system.tenantMigration.oplogView', resolve
// its view definition.
- const TenantDatabaseName involvedTenantDbName(boost::none, involvedNs.db());
- auto involvedDbViewCatalog =
- DatabaseHolder::get(opCtx)->getViewCatalog(opCtx, involvedTenantDbName);
-
- // It is safe to assume that the ViewCatalog for the `local` database always
- // exists because replica sets forbid dropping the oplog and the `local` database.
- invariant(involvedDbViewCatalog);
- auto status = resolveViewDefinition(involvedNs, involvedDbViewCatalog);
+ auto status = resolveViewDefinition(involvedNs);
if (!status.isOK()) {
return status;
}
@@ -367,8 +358,8 @@ StatusWith<StringMap<ExpressionContext::ResolvedNamespace>> resolveInvolvedNames
// that the inverse scenario (mistaking a view for a collection) is not an issue
// because $merge/$out cannot target a view.
auto nssToCheck = NamespaceString(request.getNamespace().db(), involvedNs.coll());
- if (viewCatalog && viewCatalog->lookup(opCtx, nssToCheck)) {
- auto status = resolveViewDefinition(nssToCheck, viewCatalog);
+ if (catalog->lookupView(opCtx, nssToCheck)) {
+ auto status = resolveViewDefinition(nssToCheck);
if (!status.isOK()) {
return status;
}
@@ -376,18 +367,14 @@ StatusWith<StringMap<ExpressionContext::ResolvedNamespace>> resolveInvolvedNames
resolvedNamespaces[involvedNs.coll()] = {involvedNs, std::vector<BSONObj>{}};
}
}
- } else if (!viewCatalog ||
- CollectionCatalog::get(opCtx)->lookupCollectionByNamespace(opCtx, involvedNs)) {
+ } else if (catalog->lookupCollectionByNamespace(opCtx, involvedNs)) {
// Attempt to acquire UUID of the collection using lock free method.
- auto uuid = CollectionCatalog::get(opCtx)->lookupUUIDByNSS(opCtx, involvedNs);
- // If the aggregation database exists and 'involvedNs' refers to a collection namespace,
- // then we resolve it as an empty pipeline in order to read directly from the underlying
- // collection. If the database doesn't exist, then we still resolve it as an empty
- // pipeline because 'involvedNs' doesn't refer to a view namespace in our consistent
- // snapshot of the view catalog.
+ auto uuid = catalog->lookupUUIDByNSS(opCtx, involvedNs);
+ // If 'involvedNs' refers to a collection namespace, then we resolve it as an empty
+ // pipeline in order to read directly from the underlying collection.
resolvedNamespaces[involvedNs.coll()] = {involvedNs, std::vector<BSONObj>{}, uuid};
- } else if (viewCatalog->lookup(opCtx, involvedNs)) {
- auto status = resolveViewDefinition(involvedNs, viewCatalog);
+ } else if (catalog->lookupView(opCtx, involvedNs)) {
+ auto status = resolveViewDefinition(involvedNs);
if (!status.isOK()) {
return status;
}
@@ -409,18 +396,13 @@ Status collatorCompatibleWithPipeline(OperationContext* opCtx,
StringData dbName,
const CollatorInterface* collator,
const LiteParsedPipeline& liteParsedPipeline) {
- const TenantDatabaseName tenantDbName(boost::none, dbName);
- auto viewCatalog = DatabaseHolder::get(opCtx)->getViewCatalog(opCtx, tenantDbName);
- if (!viewCatalog) {
- return Status::OK();
- }
auto catalog = CollectionCatalog::get(opCtx);
for (auto&& potentialViewNs : liteParsedPipeline.getInvolvedNamespaces()) {
if (catalog->lookupCollectionByNamespace(opCtx, potentialViewNs)) {
continue;
}
- auto view = viewCatalog->lookup(opCtx, potentialViewNs);
+ auto view = catalog->lookupView(opCtx, potentialViewNs);
if (!view) {
continue;
}
@@ -686,6 +668,7 @@ Status runAggregate(OperationContext* opCtx,
std::vector<unique_ptr<PlanExecutor, PlanExecutor::Deleter>> execs;
boost::intrusive_ptr<ExpressionContext> expCtx;
auto curOp = CurOp::get(opCtx);
+ auto catalog = CollectionCatalog::get(opCtx);
{
// If we are in a transaction, check whether the parsed pipeline supports being in
@@ -718,19 +701,15 @@ Status runAggregate(OperationContext* opCtx,
// a stream on an entire db or across the cluster.
const TenantDatabaseName origTenantDbName(boost::none, origNss.db());
if (!origNss.isCollectionlessAggregateNS()) {
- auto viewCatalog =
- DatabaseHolder::get(opCtx)->getViewCatalog(opCtx, origTenantDbName);
- if (viewCatalog) {
- auto view = viewCatalog->lookup(opCtx, origNss);
- uassert(ErrorCodes::CommandNotSupportedOnView,
- str::stream()
- << "Namespace " << origNss.ns() << " is a timeseries collection",
- !view || !view->timeseries());
- uassert(ErrorCodes::CommandNotSupportedOnView,
- str::stream()
- << "Namespace " << origNss.ns() << " is a view, not a collection",
- !view);
- }
+ auto view = catalog->lookupView(opCtx, origNss);
+ uassert(ErrorCodes::CommandNotSupportedOnView,
+ str::stream()
+ << "Namespace " << origNss.ns() << " is a timeseries collection",
+ !view || !view->timeseries());
+ uassert(ErrorCodes::CommandNotSupportedOnView,
+ str::stream()
+ << "Namespace " << origNss.ns() << " is a view, not a collection",
+ !view);
}
// If the user specified an explicit collation, adopt it; otherwise, use the simple
@@ -816,16 +795,15 @@ Status runAggregate(OperationContext* opCtx,
auto timeSeriesCollator =
ctx->getView()->timeseries() ? request.getCollation() : boost::none;
- // Check that the database/view catalog still exist, in case this is a lock-free
+ // Check that the database still exists, in case this is a lock-free
// operation. It's possible for a view to disappear after we release locks below, so
// it's safe to quit early if the view disappears while running lock-free.
const TenantDatabaseName tenantDbName(boost::none, nss.db());
- auto viewCatalog = DatabaseHolder::get(opCtx)->getViewCatalog(opCtx, tenantDbName);
uassert(ErrorCodes::NamespaceNotFound,
str::stream() << "Namespace '" << nss << "' no longer exists",
- viewCatalog);
- auto resolvedView =
- uassertStatusOK(viewCatalog->resolveView(opCtx, nss, timeSeriesCollator));
+ DatabaseHolder::get(opCtx)->dbExists(opCtx, tenantDbName));
+ auto resolvedView = uassertStatusOK(
+ view_catalog_helpers::resolveView(opCtx, catalog, nss, timeSeriesCollator));
// With the view & collation resolved, we can relinquish locks.
resetContext();
diff --git a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
index 119b9149557..81553af9c89 100644
--- a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
+++ b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
@@ -78,7 +78,6 @@
#include "mongo/db/session_txn_record_gen.h"
#include "mongo/db/timeseries/timeseries_index_schema_conversion_functions.h"
#include "mongo/db/vector_clock.h"
-#include "mongo/db/views/view_catalog.h"
#include "mongo/logv2/log.h"
#include "mongo/rpc/get_status_from_command_result.h"
#include "mongo/s/pm2423_feature_flags_gen.h"
diff --git a/src/mongo/db/commands/validate_db_metadata_cmd.cpp b/src/mongo/db/commands/validate_db_metadata_cmd.cpp
index 6af54a47d11..c3a00ff74e6 100644
--- a/src/mongo/db/commands/validate_db_metadata_cmd.cpp
+++ b/src/mongo/db/commands/validate_db_metadata_cmd.cpp
@@ -32,6 +32,7 @@
#include "mongo/platform/basic.h"
#include "mongo/db/catalog/collection.h"
+#include "mongo/db/catalog/collection_catalog.h"
#include "mongo/db/catalog/collection_catalog_helper.h"
#include "mongo/db/catalog/database_holder.h"
#include "mongo/db/catalog/index_catalog.h"
@@ -41,8 +42,9 @@
#include "mongo/db/commands/validate_db_metadata_gen.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/multitenancy.h"
-#include "mongo/db/views/view_catalog.h"
+#include "mongo/db/views/view_catalog_helpers.h"
#include "mongo/logv2/log.h"
+
namespace mongo {
namespace {
void overrideAPIParams(OperationContext* opCtx, const APIParamsForCmd& params) {
@@ -142,13 +144,10 @@ public:
// If there is no collection name present in the input, run validation against all
// the collections.
- if (auto viewCatalog =
- DatabaseHolder::get(opCtx)->getViewCatalog(opCtx, tenantDbName)) {
- viewCatalog->iterate(tenantDbName.dbName(),
- [this, opCtx](const ViewDefinition& view) {
- return _validateView(opCtx, view);
- });
- }
+ collectionCatalog->iterateViews(
+ opCtx, tenantDbName.dbName(), [this, opCtx](const ViewDefinition& view) {
+ return _validateView(opCtx, view);
+ });
for (auto collIt = collectionCatalog->begin(opCtx, tenantDbName);
collIt != collectionCatalog->end(opCtx);
@@ -166,7 +165,7 @@ public:
* Returns false, if the evaluation needs to be aborted.
*/
bool _validateView(OperationContext* opCtx, const ViewDefinition& view) {
- auto pipelineStatus = ViewCatalog::validatePipeline(opCtx, view);
+ auto pipelineStatus = view_catalog_helpers::validatePipeline(opCtx, view);
if (!pipelineStatus.isOK()) {
ErrorReplyElement error(view.name().ns(),
ErrorCodes::APIStrictError,
diff --git a/src/mongo/db/commands/write_commands.cpp b/src/mongo/db/commands/write_commands.cpp
index 9b63f16641c..e7584569d7c 100644
--- a/src/mongo/db/commands/write_commands.cpp
+++ b/src/mongo/db/commands/write_commands.cpp
@@ -33,6 +33,7 @@
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/bson/mutable/document.h"
#include "mongo/bson/mutable/element.h"
+#include "mongo/db/catalog/collection_catalog.h"
#include "mongo/db/catalog/collection_operation_source.h"
#include "mongo/db/catalog/database_holder.h"
#include "mongo/db/catalog/document_validation.h"
@@ -71,7 +72,6 @@
#include "mongo/db/timeseries/timeseries_constants.h"
#include "mongo/db/timeseries/timeseries_stats.h"
#include "mongo/db/transaction_participant.h"
-#include "mongo/db/views/view_catalog.h"
#include "mongo/db/write_concern.h"
#include "mongo/logv2/log.h"
#include "mongo/logv2/redaction.h"