diff options
| author | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-11 15:07:35 -0300 |
|---|---|---|
| committer | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-11 15:07:35 -0300 |
| commit | 4cb8841196d0625dfa3825aa326f071cd27c7b8b (patch) | |
| tree | 1682a647d4463397c119183369ae6f750d5fdcff /src/mongo/db/catalog/catalog_control.cpp | |
| parent | aa03c6362cbaa767638e6eed9b031d86dd2643d1 (diff) | |
| parent | 8f0827553e09872941945a093b647a4211a9db7f (diff) | |
Update upstream source from tag 'upstream/6.0.0'master
Update to upstream version '6.0.0'
with Debian dir 5604a80ec1c96ca76f25f40d78e6ef855abec322
Diffstat (limited to 'src/mongo/db/catalog/catalog_control.cpp')
| -rw-r--r-- | src/mongo/db/catalog/catalog_control.cpp | 68 |
1 files changed, 22 insertions, 46 deletions
diff --git a/src/mongo/db/catalog/catalog_control.cpp b/src/mongo/db/catalog/catalog_control.cpp index 19f413fc1b6..dadfed598c0 100644 --- a/src/mongo/db/catalog/catalog_control.cpp +++ b/src/mongo/db/catalog/catalog_control.cpp @@ -35,7 +35,6 @@ #include "mongo/db/catalog/catalog_control.h" -#include "mongo/db/catalog/catalog_stats.h" #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/collection_catalog.h" #include "mongo/db/catalog/database.h" @@ -44,18 +43,17 @@ #include "mongo/db/index_builds_coordinator.h" #include "mongo/db/namespace_string.h" #include "mongo/db/rebuild_indexes.h" -#include "mongo/db/repl/oplog.h" #include "mongo/db/tenant_database_name.h" -#include "mongo/db/timeseries/timeseries_extended_range.h" #include "mongo/logv2/log.h" namespace mongo { namespace catalog { namespace { -void reopenAllDatabasesAndReloadCollectionCatalog(OperationContext* opCtx, - StorageEngine* storageEngine, - const PreviousCatalogState& previousCatalogState, - Timestamp stableTimestamp) { +void reopenAllDatabasesAndReloadCollectionCatalog( + OperationContext* opCtx, + StorageEngine* storageEngine, + const MinVisibleTimestampMap& minVisibleTimestampMap, + Timestamp stableTimestamp) { // Open all databases and repopulate the CollectionCatalog. LOGV2(20276, "openCatalog: reopening all databases"); @@ -82,7 +80,7 @@ void reopenAllDatabasesAndReloadCollectionCatalog(OperationContext* opCtx, str::stream() << "failed to get valid collection pointer for namespace " << collNss); - if (previousCatalogState.minVisibleTimestampMap.count(collection->uuid()) > 0) { + if (minVisibleTimestampMap.count(collection->uuid()) > 0) { // After rolling back to a stable timestamp T, the minimum visible timestamp for // each collection must be reset to (at least) its value at T. Additionally, there // cannot exist a minimum visible timestamp greater than lastApplied. This allows us @@ -92,31 +90,14 @@ void reopenAllDatabasesAndReloadCollectionCatalog(OperationContext* opCtx, // bound the minimum visible timestamp (where necessary) to the stable timestamp. // The benefit of fine grained tracking is assumed to be low-value compared to the // cost/effort. - auto minVisible = std::min( - stableTimestamp, - previousCatalogState.minVisibleTimestampMap.find(collection->uuid())->second); + auto minVisible = std::min(stableTimestamp, + minVisibleTimestampMap.find(collection->uuid())->second); auto writableCollection = catalogWriter.get()->lookupCollectionByUUIDForMetadataWrite(opCtx, collection->uuid()); writableCollection->setMinimumVisibleSnapshot(minVisible); } - if (collection->getTimeseriesOptions()) { - bool extendedRangeSetting; - if (auto it = previousCatalogState.requiresTimestampExtendedRangeSupportMap.find( - collection->uuid()); - it != previousCatalogState.requiresTimestampExtendedRangeSupportMap.end()) { - extendedRangeSetting = it->second; - } else { - extendedRangeSetting = - timeseries::collectionMayRequireExtendedRangeSupport(opCtx, collection); - } - - if (extendedRangeSetting) { - collection->setRequiresTimeseriesExtendedRangeSupport(opCtx); - } - } - // If this is the oplog collection, re-establish the replication system's cached pointer // to the oplog. if (collNss.isOplog()) { @@ -133,25 +114,28 @@ void reopenAllDatabasesAndReloadCollectionCatalog(OperationContext* opCtx, // Opening CollectionCatalog: The collection catalog is now in sync with the storage engine // catalog. Clear the pre-closing state. - CollectionCatalog::write(opCtx, [](CollectionCatalog& catalog) { catalog.onOpenCatalog(); }); + CollectionCatalog::write(opCtx, + [&](CollectionCatalog& catalog) { catalog.onOpenCatalog(opCtx); }); opCtx->getServiceContext()->incrementCatalogGeneration(); LOGV2(20278, "openCatalog: finished reloading collection catalog"); } } // namespace -PreviousCatalogState closeCatalog(OperationContext* opCtx) { +MinVisibleTimestampMap closeCatalog(OperationContext* opCtx) { invariant(opCtx->lockState()->isW()); IndexBuildsCoordinator::get(opCtx)->assertNoIndexBuildInProgress(); - PreviousCatalogState previousCatalogState; + MinVisibleTimestampMap minVisibleTimestampMap; std::vector<TenantDatabaseName> allDbs = opCtx->getServiceContext()->getStorageEngine()->listDatabases(); auto databaseHolder = DatabaseHolder::get(opCtx); auto catalog = CollectionCatalog::get(opCtx); for (auto&& tenantDbName : allDbs) { - for (auto&& coll : catalog->range(tenantDbName)) { + for (auto collIt = catalog->begin(opCtx, tenantDbName); collIt != catalog->end(opCtx); + ++collIt) { + auto coll = *collIt; if (!coll) { break; } @@ -166,12 +150,7 @@ PreviousCatalogState closeCatalog(OperationContext* opCtx) { "coll_ns"_attr = coll->ns(), "uuid"_attr = coll->uuid(), "minVisible"_attr = minVisible); - previousCatalogState.minVisibleTimestampMap[coll->uuid()] = *minVisible; - } - - if (coll->getTimeseriesOptions()) { - previousCatalogState.requiresTimestampExtendedRangeSupportMap[coll->uuid()] = - coll->getRequiresTimeseriesExtendedRangeSupport(); + minVisibleTimestampMap[coll->uuid()] = *minVisible; } } } @@ -179,13 +158,14 @@ PreviousCatalogState closeCatalog(OperationContext* opCtx) { // Need to mark the CollectionCatalog as open if we our closeAll fails, dismissed if successful. ScopeGuard reopenOnFailure([opCtx] { CollectionCatalog::write(opCtx, - [](CollectionCatalog& catalog) { catalog.onOpenCatalog(); }); + [&](CollectionCatalog& catalog) { catalog.onOpenCatalog(opCtx); }); }); // Closing CollectionCatalog: only lookupNSSByUUID will fall back to using pre-closing state to // allow authorization for currently unknown UUIDs. This is needed because authorization needs // to work before acquiring locks, and might otherwise spuriously regard a UUID as unknown // while reloading the catalog. - CollectionCatalog::write(opCtx, [](CollectionCatalog& catalog) { catalog.onCloseCatalog(); }); + CollectionCatalog::write(opCtx, + [&](CollectionCatalog& catalog) { catalog.onCloseCatalog(opCtx); }); LOGV2_DEBUG(20270, 1, "closeCatalog: closing collection catalog"); @@ -197,16 +177,12 @@ PreviousCatalogState closeCatalog(OperationContext* opCtx) { LOGV2(20272, "closeCatalog: closing storage engine catalog"); opCtx->getServiceContext()->getStorageEngine()->closeCatalog(opCtx); - // Reset the stats counter for extended range time-series collections. This is maintained - // outside the catalog itself. - catalog_stats::requiresTimeseriesExtendedRangeSupport.store(0); - reopenOnFailure.dismiss(); - return previousCatalogState; + return minVisibleTimestampMap; } void openCatalog(OperationContext* opCtx, - const PreviousCatalogState& previousCatalogState, + const MinVisibleTimestampMap& minVisibleTimestampMap, Timestamp stableTimestamp) { invariant(opCtx->lockState()->isW()); @@ -278,7 +254,7 @@ void openCatalog(OperationContext* opCtx, opCtx, reconcileResult.indexBuildsToRestart, reconcileResult.indexBuildsToResume); reopenAllDatabasesAndReloadCollectionCatalog( - opCtx, storageEngine, previousCatalogState, stableTimestamp); + opCtx, storageEngine, minVisibleTimestampMap, stableTimestamp); } |
