diff options
Diffstat (limited to 'src/mongo/db/catalog/database_impl.cpp')
| -rw-r--r-- | src/mongo/db/catalog/database_impl.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/mongo/db/catalog/database_impl.cpp b/src/mongo/db/catalog/database_impl.cpp index 732c0c66880..5e7f720783c 100644 --- a/src/mongo/db/catalog/database_impl.cpp +++ b/src/mongo/db/catalog/database_impl.cpp @@ -67,6 +67,7 @@ #include "mongo/db/service_context.h" #include "mongo/db/stats/top.h" #include "mongo/db/storage/durable_catalog.h" +#include "mongo/db/storage/historical_ident_tracker.h" #include "mongo/db/storage/recovery_unit.h" #include "mongo/db/storage/storage_engine.h" #include "mongo/db/storage/storage_engine_init.h" @@ -564,6 +565,16 @@ Status DatabaseImpl::_finishDropCollection(OperationContext* opCtx, opCtx, collection->ns(), collection->getCatalogId(), sharedIdent); if (!status.isOK()) return status; + + opCtx->recoveryUnit()->onCommit( + [nss, uuid, ident = sharedIdent->getIdent()](OperationContext* opCtx, + boost::optional<Timestamp> commitTime) { + if (!commitTime) { + return; + } + + HistoricalIdentTracker::get(opCtx).recordDrop(ident, nss, uuid, commitTime.value()); + }); } CollectionCatalog::get(opCtx)->dropCollection( @@ -615,6 +626,30 @@ Status DatabaseImpl::renameCollection(OperationContext* opCtx, return status; CollectionCatalog::get(opCtx)->onCollectionRename(opCtx, writableCollection, fromNss); + + opCtx->recoveryUnit()->onCommit([fromNss, + writableCollection](OperationContext* opCtx, + boost::optional<Timestamp> commitTime) { + if (!commitTime) { + return; + } + + HistoricalIdentTracker::get(opCtx).recordRename( + writableCollection->getSharedIdent()->getIdent(), + fromNss, + writableCollection->uuid(), + commitTime.value()); + + const auto readyIndexes = writableCollection->getIndexCatalog()->getAllReadyEntriesShared(); + for (const auto& readyIndex : readyIndexes) { + HistoricalIdentTracker::get(opCtx).recordRename( + readyIndex->getIdent(), fromNss, writableCollection->uuid(), commitTime.value()); + } + + // Ban reading from this collection on committed reads on snapshots before now. + writableCollection->setMinimumVisibleSnapshot(commitTime.value()); + }); + return status; } |
