summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog
diff options
context:
space:
mode:
authorGregory Noma <gregory.noma@gmail.com>2020-11-25 16:52:41 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-11-25 23:03:46 +0000
commit82aea1d428e3a06994d6624464b74b92e47eae2d (patch)
treea8112379aafd05ba6e581d22d4d5584b0cb7b8e9 /src/mongo/db/catalog
parenta194505325087b1e841fdee55c51312a042ce9d2 (diff)
downloadmongo-82aea1d428e3a06994d6624464b74b92e47eae2d.tar.gz
SERVER-52523 Implement in-memory time-series bucket catalog
Diffstat (limited to 'src/mongo/db/catalog')
-rw-r--r--src/mongo/db/catalog/SConscript1
-rw-r--r--src/mongo/db/catalog/create_collection.cpp2
-rw-r--r--src/mongo/db/catalog/database_impl.cpp2
-rw-r--r--src/mongo/db/catalog/drop_collection.cpp19
-rw-r--r--src/mongo/db/catalog/drop_database.cpp3
5 files changed, 18 insertions, 9 deletions
diff --git a/src/mongo/db/catalog/SConscript b/src/mongo/db/catalog/SConscript
index 2e7152c8a7d..19f23c6310d 100644
--- a/src/mongo/db/catalog/SConscript
+++ b/src/mongo/db/catalog/SConscript
@@ -438,6 +438,7 @@ env.Library(
'$BUILD_DIR/mongo/db/index_builds_coordinator_interface',
'$BUILD_DIR/mongo/db/query_exec',
'$BUILD_DIR/mongo/db/server_options_core',
+ '$BUILD_DIR/mongo/db/timeseries/bucket_catalog',
'$BUILD_DIR/mongo/db/views/views',
'$BUILD_DIR/mongo/db/write_ops',
'collection',
diff --git a/src/mongo/db/catalog/create_collection.cpp b/src/mongo/db/catalog/create_collection.cpp
index a69f55633b2..ef867c99730 100644
--- a/src/mongo/db/catalog/create_collection.cpp
+++ b/src/mongo/db/catalog/create_collection.cpp
@@ -206,7 +206,7 @@ Status _createTimeseries(OperationContext* opCtx,
// If the buckets collection and time-series view creation roll back, ensure that their Top
// entries are deleted.
opCtx->recoveryUnit()->onRollback(
- [serviceContext = opCtx->getServiceContext(), &ns, &bucketsNs]() {
+ [serviceContext = opCtx->getServiceContext(), ns, bucketsNs]() {
Top::get(serviceContext).collectionDropped(ns);
Top::get(serviceContext).collectionDropped(bucketsNs);
});
diff --git a/src/mongo/db/catalog/database_impl.cpp b/src/mongo/db/catalog/database_impl.cpp
index 8167dd2c1a9..6ebf6dc207b 100644
--- a/src/mongo/db/catalog/database_impl.cpp
+++ b/src/mongo/db/catalog/database_impl.cpp
@@ -619,7 +619,7 @@ Status DatabaseImpl::createView(OperationContext* opCtx,
str::stream() << "invalid namespace name for a view: " + viewName.toString()};
} else {
status = ViewCatalog::get(this)->createView(
- opCtx, viewName, viewOnNss, pipeline, options.collation);
+ opCtx, viewName, viewOnNss, pipeline, options.collation, options.timeseries);
}
audit::logCreateView(&cc(), viewName.toString(), viewOnNss.toString(), pipeline, status.code());
diff --git a/src/mongo/db/catalog/drop_collection.cpp b/src/mongo/db/catalog/drop_collection.cpp
index 2642b81bc50..21264f369cf 100644
--- a/src/mongo/db/catalog/drop_collection.cpp
+++ b/src/mongo/db/catalog/drop_collection.cpp
@@ -44,6 +44,7 @@
#include "mongo/db/s/collection_sharding_state.h"
#include "mongo/db/server_options.h"
#include "mongo/db/service_context.h"
+#include "mongo/db/timeseries/bucket_catalog.h"
#include "mongo/db/views/view_catalog.h"
#include "mongo/logv2/log.h"
#include "mongo/util/fail_point.h"
@@ -70,7 +71,8 @@ Status _checkNssAndReplState(OperationContext* opCtx, const CollectionPtr& coll)
Status _dropView(OperationContext* opCtx,
Database* db,
const NamespaceString& collectionName,
- BSONObjBuilder* result) {
+ BSONObjBuilder* result,
+ bool clearBucketCatalog = false) {
if (!db) {
return Status(ErrorCodes::NamespaceNotFound, "ns not found");
}
@@ -114,6 +116,10 @@ Status _dropView(OperationContext* opCtx,
}
wunit.commit();
+ if (clearBucketCatalog) {
+ BucketCatalog::get(opCtx).clear(collectionName);
+ }
+
result->append("ns", collectionName.ns());
return Status::OK();
}
@@ -322,7 +328,7 @@ Status dropCollection(OperationContext* opCtx,
return Status(ErrorCodes::NamespaceNotFound, "ns not found");
}
- if (!view->isTimeseries()) {
+ if (!view->timeseries()) {
return _dropView(opCtx, db, collectionName, &result);
}
@@ -331,15 +337,14 @@ Status dropCollection(OperationContext* opCtx,
std::move(autoDb),
view->viewOn(),
[opCtx, &collectionName, &result](Database* db, const NamespaceString& bucketsNs) {
- WriteUnitOfWork wuow(opCtx);
- auto status = _dropView(opCtx, db, collectionName, &result);
+ auto status = _dropView(
+ opCtx, db, collectionName, &result, true /* clearBucketCatalog */);
if (!status.isOK()) {
return status;
}
- wuow.commit();
- // Drop the buckets collection in its own writeConflictRetry so that
- // if it throws a WCE, only the buckets collection drop is retried.
+ // Drop the buckets collection in its own writeConflictRetry so that if it
+ // throws a WCE, only the buckets collection drop is retried.
writeConflictRetry(opCtx, "drop", bucketsNs.ns(), [opCtx, db, &bucketsNs] {
WriteUnitOfWork wuow(opCtx);
db->dropCollectionEvenIfSystem(opCtx, bucketsNs).ignore();
diff --git a/src/mongo/db/catalog/drop_database.cpp b/src/mongo/db/catalog/drop_database.cpp
index 3a177f3f907..cbb84773fd6 100644
--- a/src/mongo/db/catalog/drop_database.cpp
+++ b/src/mongo/db/catalog/drop_database.cpp
@@ -45,6 +45,7 @@
#include "mongo/db/repl/repl_client_info.h"
#include "mongo/db/repl/replication_coordinator.h"
#include "mongo/db/service_context.h"
+#include "mongo/db/timeseries/bucket_catalog.h"
#include "mongo/db/write_concern_options.h"
#include "mongo/logv2/log.h"
#include "mongo/util/duration.h"
@@ -114,6 +115,8 @@ void _finishDropDatabase(OperationContext* opCtx,
databaseHolder->dropDb(opCtx, db);
dropPendingGuard.dismiss();
+ BucketCatalog::get(opCtx).clear(dbName);
+
LOGV2(20336,
"dropDatabase {dbName} - finished, dropped {numCollections} collection(s)",
"dropDatabase",