summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests/storage_timestamp_tests.cpp
diff options
context:
space:
mode:
authorHenrik Edin <henrik.edin@mongodb.com>2021-05-11 14:30:26 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-05-24 13:27:22 +0000
commit50547a878aaa67722f69c05b05a35236f8f0def9 (patch)
treea53d664698d14eeda6db13c43fa8612fe45ef2c9 /src/mongo/dbtests/storage_timestamp_tests.cpp
parent781ac650ef59c68fbc257e32c738e4887346159b (diff)
downloadmongo-50547a878aaa67722f69c05b05a35236f8f0def9.tar.gz
SERVER-56002 SERVER-56023 Store Collection metadata in the Collection and reply on the copy-on-write machinery to keep it in sync with the durable catalog.
All updates to the metadata needs to happen through the Collection, moved interfaces from the DurableCatalog to the Collection. Removed back pointer to Collection in IndexCatalogEntryImpl, interfaces now correctly take a const or non-const Collection. This should make its iterface const-correct to avoid making bugs where the copy-on-write system for Collections are bypassed. Multikey handle is special as it needs to happen without exclusive access to the Collection. Implemented isolation for the Collection metadata when multikey is changed. It handles multi-doc transactions and is only commited to the Collection instance after the write to the durable catalog successfully commits. listCollections and listIndexes can now safetly read the metadata cache without needing to read from the durable catalog making them safe to do without Collection level locks. (cherry picked from commit 11de948b0c50df7d12de09ae0f01e791fc5d70d7)
Diffstat (limited to 'src/mongo/dbtests/storage_timestamp_tests.cpp')
-rw-r--r--src/mongo/dbtests/storage_timestamp_tests.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/mongo/dbtests/storage_timestamp_tests.cpp b/src/mongo/dbtests/storage_timestamp_tests.cpp
index 74fbbea51bc..dd25e73d3b0 100644
--- a/src/mongo/dbtests/storage_timestamp_tests.cpp
+++ b/src/mongo/dbtests/storage_timestamp_tests.cpp
@@ -140,17 +140,17 @@ private:
const auto kIndexVersion = IndexDescriptor::IndexVersion::kV2;
-void assertIndexMetaDataMissing(const BSONCollectionCatalogEntry::MetaData& collMetaData,
+void assertIndexMetaDataMissing(std::shared_ptr<BSONCollectionCatalogEntry::MetaData> collMetaData,
StringData indexName) {
- const auto idxOffset = collMetaData.findIndexOffset(indexName);
- ASSERT_EQUALS(-1, idxOffset) << indexName << ". Collection Metdata: " << collMetaData.toBSON();
+ const auto idxOffset = collMetaData->findIndexOffset(indexName);
+ ASSERT_EQUALS(-1, idxOffset) << indexName << ". Collection Metdata: " << collMetaData->toBSON();
}
BSONCollectionCatalogEntry::IndexMetaData getIndexMetaData(
- const BSONCollectionCatalogEntry::MetaData& collMetaData, StringData indexName) {
- const auto idxOffset = collMetaData.findIndexOffset(indexName);
+ std::shared_ptr<BSONCollectionCatalogEntry::MetaData> collMetaData, StringData indexName) {
+ const auto idxOffset = collMetaData->findIndexOffset(indexName);
ASSERT_GT(idxOffset, -1) << indexName;
- return collMetaData.indexes[idxOffset];
+ return collMetaData->indexes[idxOffset];
}
class DoNothingOplogApplierObserver : public repl::OplogApplier::Observer {
@@ -245,7 +245,8 @@ public:
if (_opCtx->recoveryUnit()->getCommitTimestamp().isNull()) {
ASSERT_OK(_opCtx->recoveryUnit()->setTimestamp(Timestamp(1, 1)));
}
- collRaii.getWritableCollection()->getIndexCatalog()->dropAllIndexes(_opCtx, false);
+ collRaii.getWritableCollection()->getIndexCatalog()->dropAllIndexes(
+ _opCtx, collRaii.getWritableCollection(), false);
wunit.commit();
return;
}
@@ -327,9 +328,8 @@ public:
return optRecord.get().data.toBson();
}
- BSONCollectionCatalogEntry::MetaData getMetaDataAtTime(DurableCatalog* durableCatalog,
- RecordId catalogId,
- const Timestamp& ts) {
+ std::shared_ptr<BSONCollectionCatalogEntry::MetaData> getMetaDataAtTime(
+ DurableCatalog* durableCatalog, RecordId catalogId, const Timestamp& ts) {
OneOffRead oor(_opCtx, ts);
return durableCatalog->getMetaData(_opCtx, catalogId);
}
@@ -3308,12 +3308,12 @@ public:
auto systemViewsMd = getMetaDataAtTime(
durableCatalog, catalogId, Timestamp(systemViewsCreateTs.asULL() - 1));
- ASSERT_EQ("", systemViewsMd.ns)
+ ASSERT(systemViewsMd == nullptr)
<< systemViewsNss
<< " incorrectly exists before creation. CreateTs: " << systemViewsCreateTs;
systemViewsMd = getMetaDataAtTime(durableCatalog, catalogId, systemViewsCreateTs);
- ASSERT_EQ(systemViewsNss.ns(), systemViewsMd.ns);
+ ASSERT_EQ(systemViewsNss.ns(), systemViewsMd->ns);
assertDocumentAtTimestamp(autoColl.getCollection(), systemViewsCreateTs, BSONObj());
assertDocumentAtTimestamp(autoColl.getCollection(),