summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog
diff options
context:
space:
mode:
authorGregory Wlodarek <gregory.wlodarek@mongodb.com>2022-02-16 15:13:12 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-02-22 21:59:09 +0000
commit76a252584a8d50a5a317667f7cef24136b378b86 (patch)
tree6d0c7cef419d8359ebe8741a53e19576e451ab00 /src/mongo/db/catalog
parent762a643913be8de814c69cdf37322b2b803170c7 (diff)
downloadmongo-76a252584a8d50a5a317667f7cef24136b378b86.tar.gz
SERVER-63218 Backup cursor returns the namespace and UUID at the checkpoint timestamp the backup is being taken on
Diffstat (limited to 'src/mongo/db/catalog')
-rw-r--r--src/mongo/db/catalog/SConscript1
-rw-r--r--src/mongo/db/catalog/database_impl.cpp34
-rw-r--r--src/mongo/db/catalog/index_catalog_impl.cpp44
3 files changed, 67 insertions, 12 deletions
diff --git a/src/mongo/db/catalog/SConscript b/src/mongo/db/catalog/SConscript
index 4e1544f06bb..6f0345dce1c 100644
--- a/src/mongo/db/catalog/SConscript
+++ b/src/mongo/db/catalog/SConscript
@@ -367,6 +367,7 @@ env.Library(
'$BUILD_DIR/mongo/db/service_context',
'$BUILD_DIR/mongo/db/storage/durable_catalog_impl',
'$BUILD_DIR/mongo/db/storage/execution_context',
+ '$BUILD_DIR/mongo/db/storage/historical_ident_tracker',
'$BUILD_DIR/mongo/db/storage/key_string',
'$BUILD_DIR/mongo/db/storage/storage_engine_common',
'$BUILD_DIR/mongo/db/storage/storage_engine_impl',
diff --git a/src/mongo/db/catalog/database_impl.cpp b/src/mongo/db/catalog/database_impl.cpp
index 565147403fb..79ff87bb762 100644
--- a/src/mongo/db/catalog/database_impl.cpp
+++ b/src/mongo/db/catalog/database_impl.cpp
@@ -69,6 +69,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"
@@ -627,6 +628,16 @@ Status DatabaseImpl::_finishDropCollection(OperationContext* opCtx,
if (!status.isOK())
return status;
+ opCtx->recoveryUnit()->onCommit(
+ [opCtx, nss, uuid, ident = collection->getSharedIdent()->getIdent()](
+ boost::optional<Timestamp> commitTime) {
+ if (!commitTime) {
+ return;
+ }
+
+ HistoricalIdentTracker::get(opCtx).recordDrop(ident, nss, uuid, commitTime.get());
+ });
+
CollectionCatalog::get(opCtx)->dropCollection(opCtx, collection);
@@ -677,11 +688,26 @@ Status DatabaseImpl::renameCollection(OperationContext* opCtx,
CollectionCatalog::get(opCtx)->onCollectionRename(opCtx, writableCollection, fromNss);
- opCtx->recoveryUnit()->onCommit([writableCollection](boost::optional<Timestamp> commitTime) {
- // Ban reading from this collection on committed reads on snapshots before now.
- if (commitTime) {
- writableCollection->setMinimumVisibleSnapshot(commitTime.get());
+ opCtx->recoveryUnit()->onCommit([opCtx, fromNss, writableCollection](
+ boost::optional<Timestamp> commitTime) {
+ if (!commitTime) {
+ return;
}
+
+ HistoricalIdentTracker::get(opCtx).recordRename(
+ writableCollection->getSharedIdent()->getIdent(),
+ fromNss,
+ writableCollection->uuid(),
+ commitTime.get());
+
+ const auto readyIndexes = writableCollection->getIndexCatalog()->getAllReadyEntriesShared();
+ for (const auto& readyIndex : readyIndexes) {
+ HistoricalIdentTracker::get(opCtx).recordRename(
+ readyIndex->getIdent(), fromNss, writableCollection->uuid(), commitTime.get());
+ }
+
+ // Ban reading from this collection on committed reads on snapshots before now.
+ writableCollection->setMinimumVisibleSnapshot(commitTime.get());
});
return status;
diff --git a/src/mongo/db/catalog/index_catalog_impl.cpp b/src/mongo/db/catalog/index_catalog_impl.cpp
index 431e35dfbb3..2525730604f 100644
--- a/src/mongo/db/catalog/index_catalog_impl.cpp
+++ b/src/mongo/db/catalog/index_catalog_impl.cpp
@@ -73,6 +73,7 @@
#include "mongo/db/service_context.h"
#include "mongo/db/storage/durable_catalog.h"
#include "mongo/db/storage/execution_context.h"
+#include "mongo/db/storage/historical_ident_tracker.h"
#include "mongo/db/storage/kv/kv_engine.h"
#include "mongo/db/storage/storage_engine_init.h"
#include "mongo/db/storage/storage_parameters_gen.h"
@@ -1193,11 +1194,23 @@ Status IndexCatalogImpl::dropUnfinishedIndex(OperationContext* opCtx,
namespace {
class IndexRemoveChange final : public RecoveryUnit::Change {
public:
- IndexRemoveChange(std::shared_ptr<IndexCatalogEntry> entry,
+ IndexRemoveChange(OperationContext* opCtx,
+ const NamespaceString& nss,
+ const UUID& uuid,
+ std::shared_ptr<IndexCatalogEntry> entry,
SharedCollectionDecorations* collectionDecorations)
- : _entry(std::move(entry)), _collectionDecorations(collectionDecorations) {}
+ : _opCtx(opCtx),
+ _nss(nss),
+ _uuid(uuid),
+ _entry(std::move(entry)),
+ _collectionDecorations(collectionDecorations) {}
void commit(boost::optional<Timestamp> commitTime) final {
+ if (commitTime) {
+ HistoricalIdentTracker::get(_opCtx).recordDrop(
+ _entry->getIdent(), _nss, _uuid, commitTime.get());
+ }
+
_entry->setDropped();
}
@@ -1211,6 +1224,9 @@ public:
}
private:
+ OperationContext* _opCtx;
+ const NamespaceString _nss;
+ const UUID _uuid;
std::shared_ptr<IndexCatalogEntry> _entry;
SharedCollectionDecorations* _collectionDecorations;
};
@@ -1229,13 +1245,21 @@ Status IndexCatalogImpl::dropIndexEntry(OperationContext* opCtx,
auto released = _readyIndexes.release(entry->descriptor());
if (released) {
invariant(released.get() == entry);
- opCtx->recoveryUnit()->registerChange(std::make_unique<IndexRemoveChange>(
- std::move(released), collection->getSharedDecorations()));
+ opCtx->recoveryUnit()->registerChange(
+ std::make_unique<IndexRemoveChange>(opCtx,
+ collection->ns(),
+ collection->uuid(),
+ std::move(released),
+ collection->getSharedDecorations()));
} else {
released = _buildingIndexes.release(entry->descriptor());
invariant(released.get() == entry);
- opCtx->recoveryUnit()->registerChange(std::make_unique<IndexRemoveChange>(
- std::move(released), collection->getSharedDecorations()));
+ opCtx->recoveryUnit()->registerChange(
+ std::make_unique<IndexRemoveChange>(opCtx,
+ collection->ns(),
+ collection->uuid(),
+ std::move(released),
+ collection->getSharedDecorations()));
}
CollectionQueryInfo::get(collection).rebuildIndexData(opCtx, collection);
@@ -1433,8 +1457,12 @@ const IndexDescriptor* IndexCatalogImpl::refreshEntry(OperationContext* opCtx,
// CollectionIndexUsageTrackerDecoration (shared state among Collection instances).
auto oldEntry = _readyIndexes.release(oldDesc);
invariant(oldEntry);
- opCtx->recoveryUnit()->registerChange(std::make_unique<IndexRemoveChange>(
- std::move(oldEntry), collection->getSharedDecorations()));
+ opCtx->recoveryUnit()->registerChange(
+ std::make_unique<IndexRemoveChange>(opCtx,
+ collection->ns(),
+ collection->uuid(),
+ std::move(oldEntry),
+ collection->getSharedDecorations()));
CollectionIndexUsageTrackerDecoration::get(collection->getSharedDecorations())
.unregisterIndex(indexName);