summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog/catalog_control.cpp
diff options
context:
space:
mode:
authorHenrik Edin <henrik.edin@mongodb.com>2022-08-16 21:00:33 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-08-16 22:47:50 +0000
commite6e66274ce5e2740b5a8265a4ba0fb20856cecca (patch)
treea158921fc330a153c5008c03910b09a76d7bfd84 /src/mongo/db/catalog/catalog_control.cpp
parent77c20f24deb5d4d930161e37a635ffe7cf11761f (diff)
downloadmongo-e6e66274ce5e2740b5a8265a4ba0fb20856cecca.tar.gz
SERVER-68255 Add minValidTimestamp to Collections
It is the timestamp of the most recent DDL operation on the collection. Has different semantics from minVisibleSnapshot and will eventually replace it.
Diffstat (limited to 'src/mongo/db/catalog/catalog_control.cpp')
-rw-r--r--src/mongo/db/catalog/catalog_control.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/mongo/db/catalog/catalog_control.cpp b/src/mongo/db/catalog/catalog_control.cpp
index f1e77df3a5c..59e0769ff9f 100644
--- a/src/mongo/db/catalog/catalog_control.cpp
+++ b/src/mongo/db/catalog/catalog_control.cpp
@@ -100,6 +100,20 @@ void reopenAllDatabasesAndReloadCollectionCatalog(OperationContext* opCtx,
writableCollection->setMinimumVisibleSnapshot(minVisible);
}
+ if (auto it = previousCatalogState.minValidTimestampMap.find(collection->uuid());
+ it != previousCatalogState.minValidTimestampMap.end()) {
+ // After rolling back to a stable timestamp T, the minimum valid timestamp for each
+ // collection must be reset to (at least) its value at T. When the min valid
+ // timestamp is clamped to the stable timestamp we may end up with a pessimistic
+ // minimum valid timestamp set where the last DDL operation occured earlier. This is
+ // fine as this is just an optimization when to avoid reading the catalog from WT.
+ auto minValid = std::min(stableTimestamp, it->second);
+ auto writableCollection =
+ catalogWriter.value()->lookupCollectionByUUIDForMetadataWrite(
+ opCtx, collection->uuid());
+ writableCollection->setMinimumValidSnapshot(minValid);
+ }
+
if (collection->getTimeseriesOptions()) {
bool extendedRangeSetting;
if (auto it = previousCatalogState.requiresTimestampExtendedRangeSupportMap.find(
@@ -172,6 +186,19 @@ PreviousCatalogState closeCatalog(OperationContext* opCtx) {
previousCatalogState.minVisibleTimestampMap[coll->uuid()] = *minVisible;
}
+ boost::optional<Timestamp> minValid = coll->getMinimumValidSnapshot();
+
+ // If there's a minimum valid, invariant there's also a UUID.
+ if (minValid) {
+ LOGV2_DEBUG(6825500,
+ 1,
+ "closeCatalog: preserving min valid timestamp.",
+ "ns"_attr = coll->ns(),
+ "uuid"_attr = coll->uuid(),
+ "minVisible"_attr = minValid);
+ previousCatalogState.minValidTimestampMap[coll->uuid()] = *minValid;
+ }
+
if (coll->getTimeseriesOptions()) {
previousCatalogState.requiresTimestampExtendedRangeSupportMap[coll->uuid()] =
coll->getRequiresTimeseriesExtendedRangeSupport();