summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordi Olivares Provencio <jordi.olivares-provencio@mongodb.com>2023-03-01 16:14:41 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-03-01 16:58:12 +0000
commita687e8ade189ec0e311ded76effab420813c808d (patch)
treeb7ae0049189bbb312317433a750b06636379de72
parent550b1584bc27cac3316fa406914a146bf82cc27b (diff)
downloadmongo-a687e8ade189ec0e311ded76effab420813c808d.tar.gz
SERVER-74253 Forbid profiling collection creation as a timeseries or view
-rw-r--r--src/mongo/db/catalog/create_collection.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/mongo/db/catalog/create_collection.cpp b/src/mongo/db/catalog/create_collection.cpp
index 910dd16e1c8..571a13d3fe9 100644
--- a/src/mongo/db/catalog/create_collection.cpp
+++ b/src/mongo/db/catalog/create_collection.cpp
@@ -831,6 +831,11 @@ Status createCollection(OperationContext* opCtx,
}
if (options.isView()) {
+ // system.profile will have new document inserts due to profiling. Inserts aren't supported
+ // on views.
+ uassert(ErrorCodes::IllegalOperation,
+ "Cannot create system.profile as a view",
+ !ns.isSystemDotProfile());
uassert(ErrorCodes::OperationNotSupportedInTransaction,
str::stream() << "Cannot create a view in a multi-document "
"transaction.",
@@ -841,6 +846,11 @@ Status createCollection(OperationContext* opCtx,
return _createView(opCtx, ns, options);
} else if (options.timeseries && !ns.isTimeseriesBucketsCollection()) {
+ // system.profile must be a simple collection since new document insertions directly work
+ // against the usual collection API. See introspect.cpp for more details.
+ uassert(ErrorCodes::IllegalOperation,
+ "Cannot create system.profile as a timeseries collection",
+ !ns.isSystemDotProfile());
// This helper is designed for user-created time-series collections on primaries. If a
// time-series buckets collection is created explicitly or during replication, treat this as
// a normal collection creation.