diff options
author | Louis Williams <louis.williams@mongodb.com> | 2020-09-22 16:03:46 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-09-23 16:49:17 +0000 |
commit | 669e5650151733738ce8270e5bdf3c5759665316 (patch) | |
tree | 40e8d2b26c236fd3effe64d5fd04b7a05162f1ec /src/mongo/db/catalog/catalog_control.cpp | |
parent | 0e044981649f6712b3cc3f39bdb41c6e06546815 (diff) | |
download | mongo-669e5650151733738ce8270e5bdf3c5759665316.tar.gz |
SERVER-47866 Secondary readers do not need to reacquire PBWM lock if there are catalog conflicts
Diffstat (limited to 'src/mongo/db/catalog/catalog_control.cpp')
-rw-r--r-- | src/mongo/db/catalog/catalog_control.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/mongo/db/catalog/catalog_control.cpp b/src/mongo/db/catalog/catalog_control.cpp index a81bf952f4c..2b243b53c08 100644 --- a/src/mongo/db/catalog/catalog_control.cpp +++ b/src/mongo/db/catalog/catalog_control.cpp @@ -104,7 +104,9 @@ MinVisibleTimestampMap closeCatalog(OperationContext* opCtx) { return minVisibleTimestampMap; } -void openCatalog(OperationContext* opCtx, const MinVisibleTimestampMap& minVisibleTimestampMap) { +void openCatalog(OperationContext* opCtx, + const MinVisibleTimestampMap& minVisibleTimestampMap, + Timestamp stableTimestamp) { invariant(opCtx->lockState()->isW()); // Load the catalog in the storage engine. @@ -197,8 +199,18 @@ void openCatalog(OperationContext* opCtx, const MinVisibleTimestampMap& minVisib << "failed to get valid collection pointer for namespace " << collNss); if (minVisibleTimestampMap.count(collection->uuid()) > 0) { - collection->setMinimumVisibleSnapshot( - minVisibleTimestampMap.find(collection->uuid())->second); + // 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 + // to upper bound what the minimum visible timestamp can be coming out of rollback. + // + // Because we only save the latest minimum visible timestamp for each collection, we + // 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, + minVisibleTimestampMap.find(collection->uuid())->second); + collection->setMinimumVisibleSnapshot(minVisible); } // If this is the oplog collection, re-establish the replication system's cached pointer |