diff options
author | Daniel Gottlieb <daniel.gottlieb@mongodb.com> | 2021-01-08 13:30:33 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-01-08 19:56:20 +0000 |
commit | ca040c1f469aa0ffd68e7a0605c10145e7fb65dc (patch) | |
tree | 292dbc3aa4f45741cc2b5de76741d5766e02c536 /src/mongo/db/catalog/index_catalog_impl.cpp | |
parent | dae67dbc6db48733d8a4a6d50f07ef469735807c (diff) | |
download | mongo-ca040c1f469aa0ffd68e7a0605c10145e7fb65dc.tar.gz |
SERVER-46678: Utilize durable history across restarts.
Diffstat (limited to 'src/mongo/db/catalog/index_catalog_impl.cpp')
-rw-r--r-- | src/mongo/db/catalog/index_catalog_impl.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/mongo/db/catalog/index_catalog_impl.cpp b/src/mongo/db/catalog/index_catalog_impl.cpp index a84eb7f995d..3f7eb16770d 100644 --- a/src/mongo/db/catalog/index_catalog_impl.cpp +++ b/src/mongo/db/catalog/index_catalog_impl.cpp @@ -115,6 +115,12 @@ Status IndexCatalogImpl::init(OperationContext* opCtx) { const bool replSetMemberInStandaloneMode = getReplSetMemberInStandaloneMode(opCtx->getServiceContext()); + boost::optional<Timestamp> recoveryTs = boost::none; + if (auto storageEngine = opCtx->getServiceContext()->getStorageEngine(); + storageEngine->supportsRecoveryTimestamp()) { + recoveryTs = storageEngine->getRecoveryTimestamp(); + } + for (size_t i = 0; i < indexNames.size(); i++) { const string& indexName = indexNames[i]; BSONObj spec = @@ -162,6 +168,13 @@ Status IndexCatalogImpl::init(OperationContext* opCtx) { auto flags = CreateIndexEntryFlags::kInitFromDisk | CreateIndexEntryFlags::kIsReady; IndexCatalogEntry* entry = createIndexEntry(opCtx, std::move(descriptor), flags); fassert(17340, entry->isReady(opCtx)); + + // When initializing indexes from disk, we conservatively set the minimumVisibleSnapshot + // to non _id indexes to the recovery timestamp. The _id index is left visible. It's + // assumed if the collection is visible, it's _id is valid to be used. + if (recoveryTs && !entry->descriptor()->isIdIndex()) { + entry->setMinimumVisibleSnapshot(recoveryTs.get()); + } } } |