summaryrefslogtreecommitdiff
path: root/src/mongo/db/storage
diff options
context:
space:
mode:
authorjannaerin <golden.janna@gmail.com>2022-03-23 21:58:00 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-04-01 00:08:33 +0000
commite683ab82364fe2a9923e9035aa5eb6f8f197fbc8 (patch)
tree281a272cc76ce0087d7a4219c2acc0e7a77a7a18 /src/mongo/db/storage
parent9be91a1223cd166ce515e4b6b2abd9bd604ebfbe (diff)
downloadmongo-e683ab82364fe2a9923e9035aa5eb6f8f197fbc8.tar.gz
SERVER-64606 Remove TenantNamespace
Diffstat (limited to 'src/mongo/db/storage')
-rw-r--r--src/mongo/db/storage/backup_block.cpp4
-rw-r--r--src/mongo/db/storage/bson_collection_catalog_entry.cpp4
-rw-r--r--src/mongo/db/storage/bson_collection_catalog_entry.h3
-rw-r--r--src/mongo/db/storage/durable_catalog.h17
-rw-r--r--src/mongo/db/storage/durable_catalog_impl.cpp109
-rw-r--r--src/mongo/db/storage/durable_catalog_impl.h16
-rw-r--r--src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_sorted_impl_test.cpp7
-rw-r--r--src/mongo/db/storage/kv/durable_catalog_test.cpp146
-rw-r--r--src/mongo/db/storage/kv/kv_engine_test_harness.cpp25
-rw-r--r--src/mongo/db/storage/storage_engine_impl.cpp53
-rw-r--r--src/mongo/db/storage/storage_engine_test_fixture.h8
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp7
12 files changed, 164 insertions, 235 deletions
diff --git a/src/mongo/db/storage/backup_block.cpp b/src/mongo/db/storage/backup_block.cpp
index ce3e83f1a97..db1c9978dd7 100644
--- a/src/mongo/db/storage/backup_block.cpp
+++ b/src/mongo/db/storage/backup_block.cpp
@@ -135,14 +135,14 @@ void BackupBlock::_initialize(OperationContext* opCtx,
// Index idents will get the namespace and UUID of their respective collection.
catalog->isIndexInEntry(opCtx, e.catalogId, _filenameStem)) {
_setUuid(opCtx, catalog, e.catalogId);
- _setNamespaceString(e.tenantNs.getNss());
+ _setNamespaceString(e.nss);
break;
}
if (e.ident == _filenameStem) {
// This ident represents the collection.
_setUuid(opCtx, catalog, e.catalogId);
- _setNamespaceString(e.tenantNs.getNss());
+ _setNamespaceString(e.nss);
break;
}
}
diff --git a/src/mongo/db/storage/bson_collection_catalog_entry.cpp b/src/mongo/db/storage/bson_collection_catalog_entry.cpp
index 2e45db1a989..80012f1733c 100644
--- a/src/mongo/db/storage/bson_collection_catalog_entry.cpp
+++ b/src/mongo/db/storage/bson_collection_catalog_entry.cpp
@@ -216,7 +216,7 @@ bool BSONCollectionCatalogEntry::MetaData::eraseIndex(StringData name) {
BSONObj BSONCollectionCatalogEntry::MetaData::toBSON(bool hasExclusiveAccess) const {
BSONObjBuilder b;
- b.append("ns", tenantNs.toString());
+ b.append("ns", ns);
b.append("options", options.toBSON());
{
BSONArrayBuilder arr(b.subarrayStart("indexes"));
@@ -264,7 +264,7 @@ BSONObj BSONCollectionCatalogEntry::MetaData::toBSON(bool hasExclusiveAccess) co
}
void BSONCollectionCatalogEntry::MetaData::parse(const BSONObj& obj) {
- tenantNs = TenantNamespace::parseTenantNamespaceFromDisk(obj.getStringField("ns").toString());
+ ns = obj.getStringField("ns").toString();
if (obj["options"].isABSONObj()) {
options = uassertStatusOK(
diff --git a/src/mongo/db/storage/bson_collection_catalog_entry.h b/src/mongo/db/storage/bson_collection_catalog_entry.h
index b2afd733205..9b3d196ec0f 100644
--- a/src/mongo/db/storage/bson_collection_catalog_entry.h
+++ b/src/mongo/db/storage/bson_collection_catalog_entry.h
@@ -34,7 +34,6 @@
#include "mongo/db/catalog/collection_options.h"
#include "mongo/db/index/multikey_paths.h"
-#include "mongo/db/tenant_namespace.h"
namespace mongo {
@@ -150,7 +149,7 @@ public:
*/
bool eraseIndex(StringData name);
- TenantNamespace tenantNs;
+ std::string ns;
CollectionOptions options;
std::vector<IndexMetaData> indexes;
diff --git a/src/mongo/db/storage/durable_catalog.h b/src/mongo/db/storage/durable_catalog.h
index 089b7c4f84c..7b436eecec8 100644
--- a/src/mongo/db/storage/durable_catalog.h
+++ b/src/mongo/db/storage/durable_catalog.h
@@ -37,7 +37,6 @@
#include "mongo/db/operation_context.h"
#include "mongo/db/storage/bson_collection_catalog_entry.h"
#include "mongo/db/storage/storage_engine.h"
-#include "mongo/db/tenant_namespace.h"
namespace mongo {
/**
@@ -60,11 +59,11 @@ public:
*/
struct Entry {
Entry() {}
- Entry(RecordId catalogId, std::string ident, TenantNamespace tenantNs)
- : catalogId(catalogId), ident(std::move(ident)), tenantNs(std::move(tenantNs)) {}
+ Entry(RecordId catalogId, std::string ident, NamespaceString nss)
+ : catalogId(catalogId), ident(std::move(ident)), nss(std::move(nss)) {}
RecordId catalogId;
std::string ident;
- TenantNamespace tenantNs;
+ NamespaceString nss;
};
virtual ~DurableCatalog() {}
@@ -106,7 +105,7 @@ public:
OperationContext* opCtx, RecordId id) const = 0;
/**
- * Updates the catalog entry for the collection 'tenantNs' with the fields specified in 'md'. If
+ * Updates the catalog entry for the collection 'nss' with the fields specified in 'md'. If
* 'md.indexes' contains a new index entry, then this method generates a new index ident and
* adds it to the catalog entry.
*/
@@ -152,7 +151,7 @@ public:
*/
virtual StatusWith<std::pair<RecordId, std::unique_ptr<RecordStore>>> createCollection(
OperationContext* opCtx,
- const TenantNamespace& tenantNs,
+ const NamespaceString& nss,
const CollectionOptions& options,
bool allocateDefaultSpace) = 0;
@@ -167,7 +166,7 @@ public:
* catalog entry and contain the following fields:
* "md": A document representing the BSONCollectionCatalogEntry::MetaData of the collection.
* "idxIdent": A document containing {<index_name>: <index_ident>} pairs for all indexes.
- * "tenantNs": TenantNamespace of the collection being imported.
+ * "nss": NamespaceString of the collection being imported.
* "ident": Ident of the collection file.
*
* On success, returns an ImportResult structure containing the RecordId which identifies the
@@ -185,14 +184,14 @@ public:
};
virtual StatusWith<ImportResult> importCollection(OperationContext* opCtx,
- const TenantNamespace& tenantNs,
+ const NamespaceString& nss,
const BSONObj& metadata,
const BSONObj& storageMetadata,
const ImportOptions& importOptions) = 0;
virtual Status renameCollection(OperationContext* opCtx,
RecordId catalogId,
- const TenantNamespace& toTenantNs,
+ const NamespaceString& toNss,
BSONCollectionCatalogEntry::MetaData& md) = 0;
/**
diff --git a/src/mongo/db/storage/durable_catalog_impl.cpp b/src/mongo/db/storage/durable_catalog_impl.cpp
index 4cbd8d83b41..dbca7f09391 100644
--- a/src/mongo/db/storage/durable_catalog_impl.cpp
+++ b/src/mongo/db/storage/durable_catalog_impl.cpp
@@ -250,12 +250,12 @@ std::string DurableCatalogImpl::getFilesystemPathForDb(const std::string& dbName
}
}
-std::string DurableCatalogImpl::_newUniqueIdent(TenantNamespace tenantNs, const char* kind) {
+std::string DurableCatalogImpl::_newUniqueIdent(NamespaceString nss, const char* kind) {
// If this changes to not put _rand at the end, _hasEntryCollidingWithRand will need fixing.
stdx::lock_guard<Latch> lk(_randLock);
StringBuilder buf;
if (_directoryPerDb) {
- buf << escapeDbName(tenantNs.db()) << '/';
+ buf << escapeDbName(nss.db()) << '/';
}
buf << kind;
buf << (_directoryForIndexes ? '/' : '-');
@@ -277,8 +277,7 @@ void DurableCatalogImpl::init(OperationContext* opCtx) {
// No rollback since this is just loading already committed data.
auto ident = obj["ident"].String();
auto ns = obj["ns"].String();
- _catalogIdToEntryMap[record->id] =
- Entry(record->id, ident, TenantNamespace::parseTenantNamespaceFromDisk(ns));
+ _catalogIdToEntryMap[record->id] = Entry(record->id, ident, NamespaceString(ns));
}
// In the unlikely event that we have used this _rand before generate a new one.
@@ -302,7 +301,7 @@ std::vector<DurableCatalog::Entry> DurableCatalogImpl::getAllCatalogEntries(
auto ident = obj["ident"].String();
auto ns = obj["ns"].String();
- ret.emplace_back(record->id, ident, TenantNamespace::parseTenantNamespaceFromDisk(ns));
+ ret.emplace_back(record->id, ident, NamespaceString(ns));
}
return ret;
@@ -316,19 +315,19 @@ DurableCatalog::Entry DurableCatalogImpl::getEntry(RecordId catalogId) const {
}
StatusWith<DurableCatalog::Entry> DurableCatalogImpl::_addEntry(OperationContext* opCtx,
- TenantNamespace tenantNs,
+ NamespaceString nss,
const CollectionOptions& options) {
- invariant(opCtx->lockState()->isDbLockedForMode(tenantNs.db(), MODE_IX));
+ invariant(opCtx->lockState()->isDbLockedForMode(nss.db(), MODE_IX));
- auto ident = _newUniqueIdent(tenantNs, "collection");
+ auto ident = _newUniqueIdent(nss, "collection");
BSONObj obj;
{
BSONObjBuilder b;
- b.append("ns", tenantNs.toString());
+ b.append("ns", nss.ns());
b.append("ident", ident);
BSONCollectionCatalogEntry::MetaData md;
- md.tenantNs = tenantNs;
+ md.ns = nss.ns();
md.options = options;
// (Generic FCV reference): TODO SERVER-60912: When kLastLTS is 6.0, remove this FCV-gated
@@ -353,21 +352,21 @@ StatusWith<DurableCatalog::Entry> DurableCatalogImpl::_addEntry(OperationContext
stdx::lock_guard<Latch> lk(_catalogIdToEntryMapLock);
invariant(_catalogIdToEntryMap.find(res.getValue()) == _catalogIdToEntryMap.end());
- _catalogIdToEntryMap[res.getValue()] = {res.getValue(), ident, tenantNs};
+ _catalogIdToEntryMap[res.getValue()] = {res.getValue(), ident, nss};
opCtx->recoveryUnit()->registerChange(std::make_unique<AddIdentChange>(this, res.getValue()));
LOGV2_DEBUG(22207,
1,
- "stored meta data for {tenantNs} @ {res_getValue}",
- logAttrs(tenantNs),
+ "stored meta data for {nss} @ {res_getValue}",
+ logAttrs(nss),
"res_getValue"_attr = res.getValue());
- return {{res.getValue(), ident, tenantNs}};
+ return {{res.getValue(), ident, nss}};
}
StatusWith<DurableCatalog::Entry> DurableCatalogImpl::_importEntry(OperationContext* opCtx,
- TenantNamespace tenantNs,
+ NamespaceString nss,
const BSONObj& metadata) {
- invariant(opCtx->lockState()->isDbLockedForMode(tenantNs.db(), MODE_IX));
+ invariant(opCtx->lockState()->isDbLockedForMode(nss.db(), MODE_IX));
auto ident = metadata["ident"].String();
StatusWith<RecordId> res =
@@ -377,12 +376,11 @@ StatusWith<DurableCatalog::Entry> DurableCatalogImpl::_importEntry(OperationCont
stdx::lock_guard<Latch> lk(_catalogIdToEntryMapLock);
invariant(_catalogIdToEntryMap.find(res.getValue()) == _catalogIdToEntryMap.end());
- _catalogIdToEntryMap[res.getValue()] = {res.getValue(), ident, tenantNs};
+ _catalogIdToEntryMap[res.getValue()] = {res.getValue(), ident, nss};
opCtx->recoveryUnit()->registerChange(std::make_unique<AddIdentChange>(this, res.getValue()));
- LOGV2_DEBUG(
- 5095101, 1, "imported meta data", logAttrs(tenantNs), "metadata"_attr = res.getValue());
- return {{res.getValue(), ident, tenantNs}};
+ LOGV2_DEBUG(5095101, 1, "imported meta data", logAttrs(nss), "metadata"_attr = res.getValue());
+ return {{res.getValue(), ident, nss}};
}
std::string DurableCatalogImpl::getIndexIdent(OperationContext* opCtx,
@@ -465,6 +463,7 @@ std::shared_ptr<BSONCollectionCatalogEntry::MetaData> DurableCatalogImpl::getMet
void DurableCatalogImpl::putMetaData(OperationContext* opCtx,
RecordId catalogId,
BSONCollectionCatalogEntry::MetaData& md) {
+ NamespaceString nss(md.ns);
BSONObj obj = _findEntry(opCtx, catalogId);
{
@@ -495,7 +494,7 @@ void DurableCatalogImpl::putMetaData(OperationContext* opCtx,
continue;
}
// missing, create new
- newIdentMap.append(name, _newUniqueIdent(md.tenantNs, "index"));
+ newIdentMap.append(name, _newUniqueIdent(nss, "index"));
}
b.append("idxIdent", newIdentMap.obj());
@@ -504,7 +503,7 @@ void DurableCatalogImpl::putMetaData(OperationContext* opCtx,
obj = b.obj();
}
- if (requiresTimestampForCatalogWrite(opCtx, md.tenantNs.getNss())) {
+ if (requiresTimestampForCatalogWrite(opCtx, nss)) {
opCtx->recoveryUnit()->setMustBeTimestamped();
}
@@ -515,13 +514,13 @@ void DurableCatalogImpl::putMetaData(OperationContext* opCtx,
Status DurableCatalogImpl::_replaceEntry(OperationContext* opCtx,
RecordId catalogId,
- const TenantNamespace& toTenantNs,
+ const NamespaceString& toNss,
BSONCollectionCatalogEntry::MetaData& md) {
BSONObj old = _findEntry(opCtx, catalogId).getOwned();
{
BSONObjBuilder b;
- b.append("ns", toTenantNs.toString());
+ b.append("ns", toNss.ns());
b.append("md", md.toBSON());
b.appendElementsUnique(old);
@@ -535,16 +534,16 @@ Status DurableCatalogImpl::_replaceEntry(OperationContext* opCtx,
const auto it = _catalogIdToEntryMap.find(catalogId);
invariant(it != _catalogIdToEntryMap.end());
- TenantNamespace fromName = it->second.tenantNs;
- it->second.tenantNs = toTenantNs;
+ NamespaceString fromName = it->second.nss;
+ it->second.nss = toNss;
opCtx->recoveryUnit()->onRollback([this, catalogId, fromName]() {
stdx::lock_guard<Latch> lk(_catalogIdToEntryMapLock);
const auto it = _catalogIdToEntryMap.find(catalogId);
invariant(it != _catalogIdToEntryMap.end());
- it->second.tenantNs = fromName;
+ it->second.nss = fromName;
});
- if (requiresTimestampForCatalogWrite(opCtx, fromName.getNss())) {
+ if (requiresTimestampForCatalogWrite(opCtx, fromName)) {
opCtx->recoveryUnit()->setMustBeTimestamped();
}
@@ -566,7 +565,7 @@ Status DurableCatalogImpl::_removeEntry(OperationContext* opCtx, RecordId catalo
LOGV2_DEBUG(22212,
1,
"deleting metadata for {it_second_namespace} @ {catalogId}",
- "it_second_namespace"_attr = it->second.tenantNs,
+ "it_second_namespace"_attr = it->second.nss,
"catalogId"_attr = catalogId);
_rs->deleteRecord(opCtx, catalogId);
_catalogIdToEntryMap.erase(it);
@@ -632,9 +631,7 @@ StatusWith<std::string> DurableCatalogImpl::newOrphanedIdent(OperationContext* o
std::string identNs = ident;
std::replace(identNs.begin(), identNs.end(), '-', '_');
// TODO SERVER-62491 Use system tenantId.
- TenantNamespace tenantNs =
- TenantNamespace(boost::none,
- NamespaceString(NamespaceString::kOrphanCollectionDb,
+ NamespaceString nss(NamespaceString(NamespaceString::kOrphanCollectionDb,
NamespaceString::kOrphanCollectionPrefix + identNs));
// Generate a new UUID for the orphaned collection.
@@ -643,10 +640,10 @@ StatusWith<std::string> DurableCatalogImpl::newOrphanedIdent(OperationContext* o
BSONObj obj;
{
BSONObjBuilder b;
- b.append("ns", tenantNs.toString());
+ b.append("ns", nss.ns());
b.append("ident", ident);
BSONCollectionCatalogEntry::MetaData md;
- md.tenantNs = tenantNs;
+ md.ns = nss.ns();
// Default options with newly generated UUID.
md.options = optionsWithUUID;
b.append("md", md.toBSON());
@@ -658,30 +655,30 @@ StatusWith<std::string> DurableCatalogImpl::newOrphanedIdent(OperationContext* o
stdx::lock_guard<Latch> lk(_catalogIdToEntryMapLock);
invariant(_catalogIdToEntryMap.find(res.getValue()) == _catalogIdToEntryMap.end());
- _catalogIdToEntryMap[res.getValue()] = Entry(res.getValue(), ident, tenantNs);
+ _catalogIdToEntryMap[res.getValue()] = Entry(res.getValue(), ident, nss);
opCtx->recoveryUnit()->registerChange(std::make_unique<AddIdentChange>(this, res.getValue()));
LOGV2_DEBUG(22213,
1,
"stored meta data for orphaned collection {namespace} @ {res_getValue}",
- logAttrs(tenantNs),
+ logAttrs(nss),
"res_getValue"_attr = res.getValue());
- return {tenantNs.toString()};
+ return {nss.ns()};
}
StatusWith<std::pair<RecordId, std::unique_ptr<RecordStore>>> DurableCatalogImpl::createCollection(
OperationContext* opCtx,
- const TenantNamespace& tenantNs,
+ const NamespaceString& nss,
const CollectionOptions& options,
bool allocateDefaultSpace) {
- invariant(opCtx->lockState()->isCollectionLockedForMode(tenantNs.getNss(), MODE_IX));
- invariant(tenantNs.getNss().coll().size() > 0);
+ invariant(opCtx->lockState()->isCollectionLockedForMode(nss, MODE_IX));
+ invariant(nss.coll().size() > 0);
- if (CollectionCatalog::get(opCtx)->lookupCollectionByNamespace(opCtx, tenantNs.getNss())) {
+ if (CollectionCatalog::get(opCtx)->lookupCollectionByNamespace(opCtx, nss)) {
throw WriteConflictException();
}
- StatusWith<Entry> swEntry = _addEntry(opCtx, tenantNs, options);
+ StatusWith<Entry> swEntry = _addEntry(opCtx, nss, options);
if (!swEntry.isOK())
return swEntry.getStatus();
Entry& entry = swEntry.getValue();
@@ -695,8 +692,8 @@ StatusWith<std::pair<RecordId, std::unique_ptr<RecordStore>>> DurableCatalogImpl
}
return KeyFormat::Long;
}();
- Status status = _engine->getEngine()->createRecordStore(
- opCtx, tenantNs.getNss().ns(), entry.ident, options, keyFormat);
+ Status status =
+ _engine->getEngine()->createRecordStore(opCtx, nss.ns(), entry.ident, options, keyFormat);
if (!status.isOK())
return status;
@@ -706,8 +703,7 @@ StatusWith<std::pair<RecordId, std::unique_ptr<RecordStore>>> DurableCatalogImpl
catalog->_engine->getEngine()->dropIdent(ru, ident).ignore();
});
- auto rs =
- _engine->getEngine()->getRecordStore(opCtx, tenantNs.getNss().ns(), entry.ident, options);
+ auto rs = _engine->getEngine()->getRecordStore(opCtx, nss.ns(), entry.ident, options);
invariant(rs);
return std::pair<RecordId, std::unique_ptr<RecordStore>>(entry.catalogId, std::move(rs));
@@ -733,16 +729,16 @@ Status DurableCatalogImpl::createIndex(OperationContext* opCtx,
StatusWith<DurableCatalog::ImportResult> DurableCatalogImpl::importCollection(
OperationContext* opCtx,
- const TenantNamespace& tenantNs,
+ const NamespaceString& nss,
const BSONObj& metadata,
const BSONObj& storageMetadata,
const ImportOptions& importOptions) {
- invariant(opCtx->lockState()->isCollectionLockedForMode(tenantNs.getNss(), MODE_X));
- invariant(tenantNs.getNss().coll().size() > 0);
+ invariant(opCtx->lockState()->isCollectionLockedForMode(nss, MODE_X));
+ invariant(nss.coll().size() > 0);
uassert(ErrorCodes::NamespaceExists,
- str::stream() << "Collection already exists. NS: " << tenantNs.toString(),
- !CollectionCatalog::get(opCtx)->lookupCollectionByNamespace(opCtx, tenantNs.getNss()));
+ str::stream() << "Collection already exists. NS: " << nss.ns(),
+ !CollectionCatalog::get(opCtx)->lookupCollectionByNamespace(opCtx, nss));
BSONCollectionCatalogEntry::MetaData md;
const BSONElement mdElement = metadata["md"];
@@ -799,7 +795,7 @@ StatusWith<DurableCatalog::ImportResult> DurableCatalogImpl::importCollection(
}
}
- StatusWith<Entry> swEntry = _importEntry(opCtx, tenantNs, catalogEntry);
+ StatusWith<Entry> swEntry = _importEntry(opCtx, nss, catalogEntry);
if (!swEntry.isOK())
return swEntry.getStatus();
Entry& entry = swEntry.getValue();
@@ -825,8 +821,7 @@ StatusWith<DurableCatalog::ImportResult> DurableCatalogImpl::importCollection(
}
}
- auto rs = _engine->getEngine()->getRecordStore(
- opCtx, tenantNs.getNss().ns(), entry.ident, md.options);
+ auto rs = _engine->getEngine()->getRecordStore(opCtx, nss.ns(), entry.ident, md.options);
invariant(rs);
return DurableCatalog::ImportResult(entry.catalogId, std::move(rs), md.options.uuid.get());
@@ -834,9 +829,9 @@ StatusWith<DurableCatalog::ImportResult> DurableCatalogImpl::importCollection(
Status DurableCatalogImpl::renameCollection(OperationContext* opCtx,
RecordId catalogId,
- const TenantNamespace& toTenantNs,
+ const NamespaceString& toNss,
BSONCollectionCatalogEntry::MetaData& md) {
- return _replaceEntry(opCtx, catalogId, toTenantNs, md);
+ return _replaceEntry(opCtx, catalogId, toNss, md);
}
Status DurableCatalogImpl::dropCollection(OperationContext* opCtx, RecordId catalogId) {
@@ -846,7 +841,7 @@ Status DurableCatalogImpl::dropCollection(OperationContext* opCtx, RecordId cata
entry = _catalogIdToEntryMap[catalogId];
}
- invariant(opCtx->lockState()->isCollectionLockedForMode(entry.tenantNs.getNss(), MODE_X));
+ invariant(opCtx->lockState()->isCollectionLockedForMode(entry.nss, MODE_X));
invariant(getTotalIndexCount(opCtx, catalogId) == 0);
// Remove metadata from mdb_catalog
diff --git a/src/mongo/db/storage/durable_catalog_impl.h b/src/mongo/db/storage/durable_catalog_impl.h
index 370366cfb52..ad6863a8637 100644
--- a/src/mongo/db/storage/durable_catalog_impl.h
+++ b/src/mongo/db/storage/durable_catalog_impl.h
@@ -109,7 +109,7 @@ public:
StatusWith<std::pair<RecordId, std::unique_ptr<RecordStore>>> createCollection(
OperationContext* opCtx,
- const TenantNamespace& tenantNs,
+ const NamespaceString& nss,
const CollectionOptions& options,
bool allocateDefaultSpace);
@@ -119,14 +119,14 @@ public:
const IndexDescriptor* spec);
StatusWith<ImportResult> importCollection(OperationContext* opCtx,
- const TenantNamespace& tenantNs,
+ const NamespaceString& nss,
const BSONObj& metadata,
const BSONObj& storageMetadata,
const ImportOptions& importOptions) override;
Status renameCollection(OperationContext* opCtx,
RecordId catalogId,
- const TenantNamespace& toTenantNs,
+ const NamespaceString& toNss,
BSONCollectionCatalogEntry::MetaData& md);
Status dropCollection(OperationContext* opCtx, RecordId catalogId);
@@ -160,23 +160,23 @@ private:
BSONObj _findEntry(OperationContext* opCtx, RecordId catalogId) const;
StatusWith<Entry> _addEntry(OperationContext* opCtx,
- TenantNamespace tenantNs,
+ NamespaceString nss,
const CollectionOptions& options);
StatusWith<Entry> _importEntry(OperationContext* opCtx,
- TenantNamespace tenantNs,
+ NamespaceString nss,
const BSONObj& metadata);
Status _replaceEntry(OperationContext* opCtx,
RecordId catalogId,
- const TenantNamespace& toTenantNs,
+ const NamespaceString& toNss,
BSONCollectionCatalogEntry::MetaData& md);
Status _removeEntry(OperationContext* opCtx, RecordId catalogId);
/**
* Generates a new unique identifier for a new "thing".
- * @param tenantNs - the containing tenant namespace
+ * @param nss - the containing namespace
* @param kind - what this "thing" is, likely collection or index
*/
- std::string _newUniqueIdent(TenantNamespace tenantNs, const char* kind);
+ std::string _newUniqueIdent(NamespaceString nss, const char* kind);
std::string _newInternalIdent(StringData identStem);
diff --git a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_sorted_impl_test.cpp b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_sorted_impl_test.cpp
index 332c90cc4f1..4798342147b 100644
--- a/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_sorted_impl_test.cpp
+++ b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_sorted_impl_test.cpp
@@ -40,7 +40,6 @@
#include "mongo/db/storage/ephemeral_for_test/ephemeral_for_test_radix_store.h"
#include "mongo/db/storage/ephemeral_for_test/ephemeral_for_test_recovery_unit.h"
#include "mongo/db/storage/sorted_data_interface_test_harness.h"
-#include "mongo/db/tenant_namespace.h"
#include "mongo/unittest/unittest.h"
namespace mongo {
@@ -61,8 +60,7 @@ public:
<< "v" << static_cast<int>(IndexDescriptor::kLatestIndexVersion)
<< "unique" << true);
- auto collection =
- std::make_unique<CollectionMock>(TenantNamespace(boost::none, NamespaceString(ns)));
+ auto collection = std::make_unique<CollectionMock>(NamespaceString(ns));
IndexDescriptor desc("", spec);
invariant(desc.isIdIndex());
@@ -86,8 +84,7 @@ public:
spec = spec.addField(partialBSON.firstElement());
}
- auto collection =
- std::make_unique<CollectionMock>(TenantNamespace(boost::none, NamespaceString(ns)));
+ auto collection = std::make_unique<CollectionMock>(NamespaceString(ns));
_descs.emplace_back("", spec);
return _kvEngine.getSortedDataInterface(&opCtx, keyFormat, "ident"_sd, &_descs.back());
}
diff --git a/src/mongo/db/storage/kv/durable_catalog_test.cpp b/src/mongo/db/storage/kv/durable_catalog_test.cpp
index 6c6190ce5be..23b5100ea9f 100644
--- a/src/mongo/db/storage/kv/durable_catalog_test.cpp
+++ b/src/mongo/db/storage/kv/durable_catalog_test.cpp
@@ -46,8 +46,6 @@
#include "mongo/db/storage/devnull/devnull_kv_engine.h"
#include "mongo/db/storage/kv/kv_engine.h"
#include "mongo/db/storage/storage_engine_impl.h"
-#include "mongo/db/tenant_id.h"
-#include "mongo/db/tenant_namespace.h"
#include "mongo/db/timeseries/timeseries_options.h"
#include "mongo/unittest/death_test.h"
#include "mongo/unittest/unittest.h"
@@ -67,12 +65,12 @@ public:
void setUp() final {
CatalogTestFixture::setUp();
- _tenantNs = TenantNamespace(boost::none, NamespaceString("unittests.durable_catalog"));
- _collectionUUID = createCollection(_tenantNs, CollectionOptions());
+ _nss = NamespaceString("unittests.durable_catalog");
+ _collectionUUID = createCollection(_nss, CollectionOptions());
}
- TenantNamespace tenantNs() {
- return _tenantNs;
+ NamespaceString ns() {
+ return _nss;
}
DurableCatalog* getCatalog() {
@@ -89,17 +87,17 @@ public:
operationContext(), *_collectionUUID, CollectionCatalog::LifetimeMode::kInplace);
}
- UUID createCollection(const TenantNamespace& tenantNs, CollectionOptions options) {
- Lock::DBLock dbLk(operationContext(), tenantNs.getNss().db(), MODE_IX);
- Lock::CollectionLock collLk(operationContext(), tenantNs.getNss(), MODE_IX);
+ UUID createCollection(const NamespaceString& nss, CollectionOptions options) {
+ Lock::DBLock dbLk(operationContext(), nss.db(), MODE_IX);
+ Lock::CollectionLock collLk(operationContext(), nss, MODE_IX);
WriteUnitOfWork wuow(operationContext());
const bool allocateDefaultSpace = true;
options.uuid = UUID::gen();
- auto swColl = getCatalog()->createCollection(
- operationContext(), tenantNs, options, allocateDefaultSpace);
+ auto swColl =
+ getCatalog()->createCollection(operationContext(), nss, options, allocateDefaultSpace);
ASSERT_OK(swColl.getStatus());
std::pair<RecordId, std::unique_ptr<RecordStore>> coll = std::move(swColl.getValue());
@@ -107,7 +105,7 @@ public:
std::shared_ptr<Collection> collection = std::make_shared<CollectionImpl>(
operationContext(),
- tenantNs,
+ nss,
catalogId,
getCatalog()->getMetaData(operationContext(), catalogId),
std::move(coll.second));
@@ -124,8 +122,8 @@ public:
IndexCatalogEntry* createIndex(BSONObj keyPattern,
std::string indexType = IndexNames::BTREE,
bool twoPhase = false) {
- Lock::DBLock dbLk(operationContext(), _tenantNs.getNss().db(), MODE_IX);
- Lock::CollectionLock collLk(operationContext(), _tenantNs.getNss(), MODE_X);
+ Lock::DBLock dbLk(operationContext(), _nss.db(), MODE_IX);
+ Lock::CollectionLock collLk(operationContext(), _nss, MODE_X);
std::string indexName = "idx" + std::to_string(_numIndexesCreated);
// Make sure we have a valid IndexSpec for the type requested
@@ -168,15 +166,15 @@ public:
ASSERT(match);
}
- StatusWith<DurableCatalog::ImportResult> importCollectionTest(const TenantNamespace& tenantNs,
+ StatusWith<DurableCatalog::ImportResult> importCollectionTest(const NamespaceString& nss,
const BSONObj& metadata) {
- Lock::DBLock dbLock(operationContext(), tenantNs.getNss().db(), MODE_IX);
- Lock::CollectionLock collLock(operationContext(), tenantNs.getNss(), MODE_X);
+ Lock::DBLock dbLock(operationContext(), nss.db(), MODE_IX);
+ Lock::CollectionLock collLock(operationContext(), nss, MODE_X);
WriteUnitOfWork wuow(operationContext());
auto res = getCatalog()->importCollection(
operationContext(),
- tenantNs,
+ nss,
metadata,
BSON("storage"
<< "metadata"),
@@ -204,7 +202,7 @@ private:
return ss.str();
}
- TenantNamespace _tenantNs;
+ NamespaceString _nss;
size_t _numIndexesCreated = 0;
@@ -520,17 +518,16 @@ DEATH_TEST_REGEX_F(DurableCatalogTest,
TEST_F(DurableCatalogTest, ImportCollection) {
// Import should fail if the namespace already exists.
ASSERT_THROWS_CODE(
- importCollectionTest(tenantNs(), {}), AssertionException, ErrorCodes::NamespaceExists);
+ importCollectionTest(ns(), {}), AssertionException, ErrorCodes::NamespaceExists);
- const auto tenantNs = TenantNamespace(boost::none, NamespaceString("unittest.import"));
+ const auto nss = NamespaceString("unittest.import");
// Import should fail with empty metadata.
- ASSERT_THROWS_CODE(
- importCollectionTest(tenantNs, {}), AssertionException, ErrorCodes::BadValue);
+ ASSERT_THROWS_CODE(importCollectionTest(nss, {}), AssertionException, ErrorCodes::BadValue);
BSONCollectionCatalogEntry::MetaData md;
- md.tenantNs = tenantNs;
+ md.ns = nss.ns();
CollectionOptions optionsWithUUID;
optionsWithUUID.uuid = UUID::gen();
@@ -550,29 +547,27 @@ TEST_F(DurableCatalogTest, ImportCollection) {
// Import should fail with missing "md" field.
ASSERT_THROWS_CODE(
importCollectionTest(
- tenantNs,
- BSON("idxIdent" << idxIdentObj << "ns" << tenantNs.toString() << "ident" << ident)),
+ nss, BSON("idxIdent" << idxIdentObj << "ns" << nss.ns() << "ident" << ident)),
AssertionException,
ErrorCodes::BadValue);
// Import should fail with missing "ident" field.
- ASSERT_THROWS_CODE(importCollectionTest(tenantNs,
- BSON("md" << mdObj << "idxIdent" << idxIdentObj << "ns"
- << tenantNs.toString())),
- AssertionException,
- ErrorCodes::BadValue);
+ ASSERT_THROWS_CODE(
+ importCollectionTest(nss,
+ BSON("md" << mdObj << "idxIdent" << idxIdentObj << "ns" << nss.ns())),
+ AssertionException,
+ ErrorCodes::BadValue);
// Import should success with validate inputs.
- auto swImportResult =
- importCollectionTest(tenantNs,
- BSON("md" << mdObj << "idxIdent" << idxIdentObj << "ns"
- << tenantNs.toString() << "ident" << ident));
+ auto swImportResult = importCollectionTest(
+ nss,
+ BSON("md" << mdObj << "idxIdent" << idxIdentObj << "ns" << nss.ns() << "ident" << ident));
ASSERT_OK(swImportResult.getStatus());
DurableCatalog::ImportResult importResult = std::move(swImportResult.getValue());
// Validate the catalog entry for the imported collection.
auto entry = getCatalog()->getEntry(importResult.catalogId);
- ASSERT_EQ(entry.tenantNs, tenantNs);
+ ASSERT_EQ(entry.nss, nss);
ASSERT_EQ(entry.ident, ident);
ASSERT_EQ(getCatalog()->getIndexIdent(operationContext(), importResult.catalogId, "_id_"),
idxIdent);
@@ -583,17 +578,17 @@ TEST_F(DurableCatalogTest, ImportCollection) {
// match.
md.options.uuid = importResult.uuid;
ASSERT_BSONOBJ_EQ(getCatalog()->getCatalogEntry(operationContext(), importResult.catalogId),
- BSON("md" << md.toBSON() << "idxIdent" << idxIdentObj << "ns"
- << tenantNs.toString() << "ident" << ident));
+ BSON("md" << md.toBSON() << "idxIdent" << idxIdentObj << "ns" << nss.ns()
+ << "ident" << ident));
}
TEST_F(DurableCatalogTest, IdentSuffixUsesRand) {
const std::string rand = "0000000000000000000";
getCatalog()->setRand_forTest(rand);
- const TenantNamespace tenantNs = TenantNamespace(boost::none, NamespaceString("a.b"));
+ const NamespaceString nss = NamespaceString("a.b");
- auto uuid = createCollection(tenantNs, CollectionOptions());
+ auto uuid = createCollection(nss, CollectionOptions());
auto collection = CollectionCatalog::get(operationContext())
->lookupCollectionByUUID(operationContext(), uuid);
RecordId catalogId = collection->getCatalogId();
@@ -608,10 +603,9 @@ TEST_F(DurableCatalogTest, ImportCollectionRandConflict) {
{
// Import a collection with the 'rand' suffix as part of the ident. This will force 'rand'
// to be changed in the durable catalog internals.
- const TenantNamespace tenantNs =
- TenantNamespace(boost::none, NamespaceString("unittest.import"));
+ const NamespaceString nss = NamespaceString("unittest.import");
BSONCollectionCatalogEntry::MetaData md;
- md.tenantNs = tenantNs;
+ md.ns = nss.ns();
CollectionOptions optionsWithUUID;
optionsWithUUID.uuid = UUID::gen();
@@ -629,9 +623,9 @@ TEST_F(DurableCatalogTest, ImportCollectionRandConflict) {
auto idxIdentObj = BSON("_id_" << idxIdent);
auto swImportResult =
- importCollectionTest(tenantNs,
- BSON("md" << mdObj << "idxIdent" << idxIdentObj << "ns"
- << tenantNs.toString() << "ident" << ident));
+ importCollectionTest(nss,
+ BSON("md" << mdObj << "idxIdent" << idxIdentObj << "ns" << nss.ns()
+ << "ident" << ident));
ASSERT_OK(swImportResult.getStatus());
}
@@ -639,8 +633,8 @@ TEST_F(DurableCatalogTest, ImportCollectionRandConflict) {
{
// Check that a newly created collection doesn't use 'rand' as the suffix in the ident.
- const TenantNamespace tenantNs = TenantNamespace(boost::none, NamespaceString("a.b"));
- createCollection(tenantNs, CollectionOptions());
+ const NamespaceString nss = NamespaceString("a.b");
+ createCollection(nss, CollectionOptions());
RecordId catalogId = getCollection()->getCatalogId();
ASSERT(!StringData(getCatalog()->getEntry(catalogId).ident).endsWith(rand));
@@ -654,13 +648,11 @@ TEST_F(DurableCatalogTest, CheckTimeseriesBucketsMayHaveMixedSchemaDataFlagFCVLa
serverGlobalParams.mutableFeatureCompatibility.setVersion(multiversion::GenericFCV::kLatest);
{
- const TenantNamespace regularTenantNs =
- TenantNamespace(boost::none, NamespaceString("test.regular"));
- createCollection(regularTenantNs, CollectionOptions());
+ const NamespaceString regularNss = NamespaceString("test.regular");
+ createCollection(regularNss, CollectionOptions());
- auto collection =
- CollectionCatalog::get(operationContext())
- ->lookupCollectionByNamespace(operationContext(), regularTenantNs.getNss());
+ auto collection = CollectionCatalog::get(operationContext())
+ ->lookupCollectionByNamespace(operationContext(), regularNss);
RecordId catalogId = collection->getCatalogId();
ASSERT(!getCatalog()
->getMetaData(operationContext(), catalogId)
@@ -668,15 +660,13 @@ TEST_F(DurableCatalogTest, CheckTimeseriesBucketsMayHaveMixedSchemaDataFlagFCVLa
}
{
- const TenantNamespace bucketsTenantNs =
- TenantNamespace(boost::none, NamespaceString("system.buckets.ts"));
+ const NamespaceString bucketsNss = NamespaceString("system.buckets.ts");
CollectionOptions options;
options.timeseries = TimeseriesOptions(/*timeField=*/"t");
- createCollection(bucketsTenantNs, options);
+ createCollection(bucketsNss, options);
- auto collection =
- CollectionCatalog::get(operationContext())
- ->lookupCollectionByNamespace(operationContext(), bucketsTenantNs.getNss());
+ auto collection = CollectionCatalog::get(operationContext())
+ ->lookupCollectionByNamespace(operationContext(), bucketsNss);
RecordId catalogId = collection->getCatalogId();
ASSERT(getCatalog()
->getMetaData(operationContext(), catalogId)
@@ -687,41 +677,5 @@ TEST_F(DurableCatalogTest, CheckTimeseriesBucketsMayHaveMixedSchemaDataFlagFCVLa
}
}
-TEST_F(DurableCatalogTest, CreateCollectionCatalogEntryHasCorrectTenantNamespace) {
- gMultitenancySupport = true;
-
- auto tenantId = TenantId(OID::gen());
- const TenantNamespace tenantNs = TenantNamespace(tenantId, NamespaceString("test.regular"));
- createCollection(tenantNs, CollectionOptions());
-
- auto collection = CollectionCatalog::get(operationContext())
- ->lookupCollectionByNamespace(operationContext(), tenantNs.getNss());
- RecordId catalogId = collection->getCatalogId();
- ASSERT_EQ(getCatalog()->getEntry(catalogId).tenantNs, tenantNs);
-}
-
-TEST_F(DurableCatalogTest, ImportCollectionCatalogEntryHasCorrectTenantNamespace) {
- gMultitenancySupport = true;
-
- auto tenantId = TenantId(OID::gen());
- const TenantNamespace tenantNs = TenantNamespace(tenantId, NamespaceString("unittest.import"));
-
- BSONCollectionCatalogEntry::MetaData md;
- md.tenantNs = tenantNs;
- CollectionOptions optionsWithUUID;
- optionsWithUUID.uuid = UUID::gen();
- md.options = optionsWithUUID;
- auto mdObj = md.toBSON();
- const auto ident = "collection-1-1234567891234567899";
-
- auto swImportResult = importCollectionTest(
- tenantNs, BSON("md" << mdObj << "ns" << tenantNs.toString() << "ident" << ident));
- ASSERT_OK(swImportResult.getStatus());
-
- auto entry = getCatalog()->getEntry(swImportResult.getValue().catalogId);
- ASSERT_EQ(entry.tenantNs, tenantNs);
- ASSERT_EQ(entry.ident, ident);
-}
-
} // namespace
} // namespace mongo
diff --git a/src/mongo/db/storage/kv/kv_engine_test_harness.cpp b/src/mongo/db/storage/kv/kv_engine_test_harness.cpp
index 3b314acec8e..e774531904f 100644
--- a/src/mongo/db/storage/kv/kv_engine_test_harness.cpp
+++ b/src/mongo/db/storage/kv/kv_engine_test_harness.cpp
@@ -31,14 +31,12 @@
#include "mongo/db/catalog/collection_impl.h"
#include "mongo/db/index/index_descriptor.h"
-#include "mongo/db/multitenancy.h"
#include "mongo/db/operation_context_noop.h"
#include "mongo/db/service_context_test_fixture.h"
#include "mongo/db/storage/durable_catalog_impl.h"
#include "mongo/db/storage/kv/kv_engine.h"
#include "mongo/db/storage/record_store.h"
#include "mongo/db/storage/sorted_data_interface.h"
-#include "mongo/db/tenant_namespace.h"
#include "mongo/unittest/death_test.h"
#include "mongo/unittest/unittest.h"
#include "mongo/util/assert_util.h"
@@ -85,8 +83,7 @@ protected:
const CollectionOptions& options,
DurableCatalogImpl* catalog) {
Lock::DBLock dbLk(opCtx, ns.db(), MODE_IX);
- TenantNamespace tenantNs(boost::none, ns);
- auto swEntry = catalog->_addEntry(opCtx, tenantNs, options);
+ auto swEntry = catalog->_addEntry(opCtx, ns, options);
ASSERT_OK(swEntry.getStatus());
return swEntry.getValue().catalogId;
}
@@ -243,7 +240,7 @@ TEST_F(KVEngineTestHarness, SimpleSorted1) {
ASSERT(engine);
std::string ident = "abc";
- auto tenantNs = TenantNamespace(boost::none, NamespaceString("mydb.mycoll"));
+ auto nss = NamespaceString("mydb.mycoll");
CollectionOptions options;
options.uuid = UUID::gen();
@@ -262,8 +259,8 @@ TEST_F(KVEngineTestHarness, SimpleSorted1) {
{
auto opCtx = _makeOperationContext(engine);
WriteUnitOfWork uow(opCtx.get());
- collection = std::make_unique<CollectionImpl>(
- opCtx.get(), tenantNs, RecordId(0), options, std::move(rs));
+ collection =
+ std::make_unique<CollectionImpl>(opCtx.get(), nss, RecordId(0), options, std::move(rs));
uow.commit();
}
@@ -1263,7 +1260,7 @@ TEST_F(DurableCatalogImplTest, Idx1) {
WriteUnitOfWork uow(opCtx);
BSONCollectionCatalogEntry::MetaData md;
- md.tenantNs = TenantNamespace(boost::none, NamespaceString("a.b"));
+ md.ns = "a.b";
BSONCollectionCatalogEntry::IndexMetaData imd;
imd.spec = BSON("name"
@@ -1297,7 +1294,7 @@ TEST_F(DurableCatalogImplTest, Idx1) {
WriteUnitOfWork uow(opCtx);
BSONCollectionCatalogEntry::MetaData md;
- md.tenantNs = TenantNamespace(boost::none, NamespaceString("a.b"));
+ md.ns = "a.b";
putMetaData(opCtx, catalog.get(), catalogId, md); // remove index
BSONCollectionCatalogEntry::IndexMetaData imd;
@@ -1351,7 +1348,7 @@ TEST_F(DurableCatalogImplTest, DirectoryPerDb1) {
WriteUnitOfWork uow(opCtx);
BSONCollectionCatalogEntry::MetaData md;
- md.tenantNs = TenantNamespace(boost::none, NamespaceString("a.b"));
+ md.ns = "a.b";
BSONCollectionCatalogEntry::IndexMetaData imd;
imd.spec = BSON("name"
@@ -1401,7 +1398,7 @@ TEST_F(DurableCatalogImplTest, Split1) {
WriteUnitOfWork uow(opCtx);
BSONCollectionCatalogEntry::MetaData md;
- md.tenantNs = TenantNamespace(boost::none, NamespaceString("a.b"));
+ md.ns = "a.b";
BSONCollectionCatalogEntry::IndexMetaData imd;
imd.spec = BSON("name"
@@ -1451,7 +1448,7 @@ TEST_F(DurableCatalogImplTest, DirectoryPerAndSplit1) {
WriteUnitOfWork uow(opCtx);
BSONCollectionCatalogEntry::MetaData md;
- md.tenantNs = TenantNamespace(boost::none, NamespaceString("a.b"));
+ md.ns = "a.b";
BSONCollectionCatalogEntry::IndexMetaData imd;
imd.spec = BSON("name"
@@ -1487,7 +1484,7 @@ DEATH_TEST_REGEX_F(DurableCatalogImplTest,
ASSERT(engine);
std::string ident = "abc";
- auto tenantNs = TenantNamespace(boost::none, NamespaceString("mydb.mycoll"));
+ auto nss = NamespaceString("mydb.mycoll");
CollectionOptions options;
options.uuid = UUID::gen();
@@ -1508,7 +1505,7 @@ DEATH_TEST_REGEX_F(DurableCatalogImplTest,
auto opCtx = clientAndCtx.opCtx();
WriteUnitOfWork uow(opCtx);
collection =
- std::make_unique<CollectionImpl>(opCtx, tenantNs, RecordId(0), options, std::move(rs));
+ std::make_unique<CollectionImpl>(opCtx, nss, RecordId(0), options, std::move(rs));
uow.commit();
}
diff --git a/src/mongo/db/storage/storage_engine_impl.cpp b/src/mongo/db/storage/storage_engine_impl.cpp
index 3cd59bcab96..a188d7160dc 100644
--- a/src/mongo/db/storage/storage_engine_impl.cpp
+++ b/src/mongo/db/storage/storage_engine_impl.cpp
@@ -182,7 +182,7 @@ void StorageEngineImpl::loadCatalog(OperationContext* opCtx, LastShutdownState l
"Historical entry",
"catalogId"_attr = entry.catalogId,
"ident"_attr = entry.ident,
- logAttrs(entry.tenantNs));
+ logAttrs(entry.nss));
}
}
@@ -252,7 +252,7 @@ void StorageEngineImpl::loadCatalog(OperationContext* opCtx, LastShutdownState l
if (!restoredIdent) {
LOGV2(6260800,
"Removing catalog entry for collection not restored",
- logAttrs(entry.tenantNs.getNss()),
+ logAttrs(entry.nss),
"ident"_attr = collectionIdent);
WriteUnitOfWork wuow(opCtx);
@@ -279,16 +279,14 @@ void StorageEngineImpl::loadCatalog(OperationContext* opCtx, LastShutdownState l
// store, drop it from the catalog and skip initializing it by continuing past the
// following logic.
if (orphan) {
- // TODO SERVER-62917 pass the TenantNamespace here so it's accessible when creating
- // the RecordStore in recoverOrphanedIdent.
- auto status = _recoverOrphanedCollection(
- opCtx, entry.catalogId, entry.tenantNs.getNss(), collectionIdent);
+ auto status =
+ _recoverOrphanedCollection(opCtx, entry.catalogId, entry.nss, collectionIdent);
if (!status.isOK()) {
LOGV2_WARNING(22266,
"Failed to recover orphaned data file for collection "
"'{namespace}': {error}",
"Failed to recover orphaned data file for collection",
- "namespace"_attr = entry.tenantNs,
+ "namespace"_attr = entry.nss,
"error"_attr = status);
WriteUnitOfWork wuow(opCtx);
fassert(50716, _catalog->_removeEntry(opCtx, entry.catalogId));
@@ -296,7 +294,7 @@ void StorageEngineImpl::loadCatalog(OperationContext* opCtx, LastShutdownState l
if (_options.forRepair) {
StorageRepairObserver::get(getGlobalServiceContext())
->invalidatingModification(str::stream()
- << "Collection " << entry.tenantNs.toString()
+ << "Collection " << entry.nss.ns()
<< " dropped: " << status.reason());
}
wuow.commit();
@@ -305,7 +303,7 @@ void StorageEngineImpl::loadCatalog(OperationContext* opCtx, LastShutdownState l
}
}
- if (!entry.tenantNs.getNss().isReplicated() &&
+ if (!entry.nss.isReplicated() &&
!std::binary_search(identsKnownToStorageEngine.begin(),
identsKnownToStorageEngine.end(),
entry.ident)) {
@@ -320,7 +318,7 @@ void StorageEngineImpl::loadCatalog(OperationContext* opCtx, LastShutdownState l
LOGV2_INFO(5555201,
"Removed unknown unreplicated collection from the catalog",
"catalogId"_attr = entry.catalogId,
- logAttrs(entry.tenantNs),
+ logAttrs(entry.nss),
"ident"_attr = entry.ident);
continue;
}
@@ -350,11 +348,10 @@ void StorageEngineImpl::loadCatalog(OperationContext* opCtx, LastShutdownState l
});
}
- _initCollection(
- opCtx, entry.catalogId, entry.tenantNs.getNss(), _options.forRepair, minVisibleTs);
+ _initCollection(opCtx, entry.catalogId, entry.nss, _options.forRepair, minVisibleTs);
- if (entry.tenantNs.getNss().isOrphanCollection()) {
- LOGV2(22248, "Orphaned collection found", logAttrs(entry.tenantNs));
+ if (entry.nss.isOrphanCollection()) {
+ LOGV2(22248, "Orphaned collection found", logAttrs(entry.nss));
}
}
@@ -384,8 +381,7 @@ void StorageEngineImpl::_initCollection(OperationContext* opCtx,
}
auto collectionFactory = Collection::Factory::get(getGlobalServiceContext());
- TenantNamespace tenantNs(getActiveTenant(opCtx), nss);
- auto collection = collectionFactory->make(opCtx, tenantNs, catalogId, md, std::move(rs));
+ auto collection = collectionFactory->make(opCtx, nss, catalogId, md, std::move(rs));
collection->setMinimumVisibleSnapshot(minVisibleTs);
CollectionCatalog::write(opCtx, [&](CollectionCatalog& catalog) {
@@ -453,7 +449,7 @@ void StorageEngineImpl::_checkForIndexFiles(
LOGV2_FATAL_NOTRACE(6261000,
"Collection is missing an index file",
- logAttrs(entry.tenantNs.getNss()),
+ logAttrs(entry.nss),
"collectionIdent"_attr = entry.ident,
"missingIndexIdent"_attr = indexIdent);
}
@@ -625,7 +621,7 @@ StatusWith<StorageEngine::ReconcileResult> StorageEngineImpl::reconcileCatalogAn
if (engineIdents.find(entry.ident) == engineIdents.end()) {
return {ErrorCodes::UnrecoverableRollbackError,
str::stream() << "Expected collection does not exist. Collection: "
- << entry.tenantNs.toString() << " Ident: " << entry.ident};
+ << entry.nss.ns() << " Ident: " << entry.ident};
}
}
}
@@ -638,7 +634,7 @@ StatusWith<StorageEngine::ReconcileResult> StorageEngineImpl::reconcileCatalogAn
for (DurableCatalog::Entry entry : catalogEntries) {
std::shared_ptr<BSONCollectionCatalogEntry::MetaData> metaData =
_catalog->getMetaData(opCtx, entry.catalogId);
- auto tenantNs = metaData->tenantNs;
+ NamespaceString nss(metaData->ns);
// Batch up the indexes to remove them from `metaData` outside of the iterator.
std::vector<std::string> indexesToDrop;
@@ -666,7 +662,7 @@ StatusWith<StorageEngine::ReconcileResult> StorageEngineImpl::reconcileCatalogAn
"the index, or rerunning with the --repair option. See "
"http://dochub.mongodb.org/core/repair for more information",
"index"_attr = indexName,
- logAttrs(tenantNs));
+ logAttrs(nss));
}
// Two-phase index drop ensures that the underlying data table for an index in the
@@ -683,7 +679,7 @@ StatusWith<StorageEngine::ReconcileResult> StorageEngineImpl::reconcileCatalogAn
lastShutdownState == LastShutdownState::kUnclean,
str::stream() << "Failed to find an index data table matching " << indexIdent
<< " for durable index catalog entry " << indexMetaData.spec
- << " in collection " << tenantNs.toString());
+ << " in collection " << nss.ns());
// Any index build with a UUID is an unfinished two-phase build and must be restarted.
// There are no special cases to handle on primaries or secondaries. An index build may
@@ -698,7 +694,7 @@ StatusWith<StorageEngine::ReconcileResult> StorageEngineImpl::reconcileCatalogAn
LOGV2(22253,
"Found index from unfinished build",
- logAttrs(tenantNs),
+ logAttrs(nss),
"uuid"_attr = *collUUID,
"index"_attr = indexName,
"buildUUID"_attr = buildUUID);
@@ -722,10 +718,10 @@ StatusWith<StorageEngine::ReconcileResult> StorageEngineImpl::reconcileCatalogAn
LOGV2(22255,
"Expected background index build did not complete, rebuilding in foreground "
"- see SERVER-43097",
- logAttrs(tenantNs),
+ logAttrs(nss),
"index"_attr = indexName);
reconcileResult.indexesToRebuild.push_back(
- {entry.catalogId, tenantNs.getNss(), indexName.toString()});
+ {entry.catalogId, nss, indexName.toString()});
continue;
}
@@ -736,10 +732,7 @@ StatusWith<StorageEngine::ReconcileResult> StorageEngineImpl::reconcileCatalogAn
// index when it replays the oplog. In these cases the index entry in the catalog
// should be dropped.
if (!indexMetaData.ready && !indexMetaData.isBackgroundSecondaryBuild) {
- LOGV2(22256,
- "Dropping unfinished index",
- logAttrs(tenantNs),
- "index"_attr = indexName);
+ LOGV2(22256, "Dropping unfinished index", logAttrs(nss), "index"_attr = indexName);
// Ensure the `ident` is dropped while we have the `indexIdent` value.
fassert(50713, _engine->dropIdent(opCtx->recoveryUnit(), indexIdent));
indexesToDrop.push_back(indexName.toString());
@@ -749,14 +742,14 @@ StatusWith<StorageEngine::ReconcileResult> StorageEngineImpl::reconcileCatalogAn
for (auto&& indexName : indexesToDrop) {
invariant(metaData->eraseIndex(indexName),
- str::stream() << "Index is missing. Collection: " << tenantNs.toString()
+ str::stream() << "Index is missing. Collection: " << nss.ns()
<< " Index: " << indexName);
}
if (indexesToDrop.size() > 0) {
WriteUnitOfWork wuow(opCtx);
auto collection =
CollectionCatalog::get(opCtx)->lookupCollectionByNamespaceForMetadataWrite(
- opCtx, CollectionCatalog::LifetimeMode::kInplace, entry.tenantNs.getNss());
+ opCtx, CollectionCatalog::LifetimeMode::kInplace, entry.nss);
invariant(collection->getCatalogId() == entry.catalogId);
collection->replaceMetadata(opCtx, std::move(metaData));
wuow.commit();
diff --git a/src/mongo/db/storage/storage_engine_test_fixture.h b/src/mongo/db/storage/storage_engine_test_fixture.h
index ae38723188a..90405371c55 100644
--- a/src/mongo/db/storage/storage_engine_test_fixture.h
+++ b/src/mongo/db/storage/storage_engine_test_fixture.h
@@ -67,7 +67,6 @@ public:
StatusWith<DurableCatalog::Entry> createCollection(OperationContext* opCtx,
NamespaceString ns) {
- TenantNamespace tenantNs(boost::none, ns);
AutoGetDb db(opCtx, ns.db(), LockMode::MODE_X);
CollectionOptions options;
options.uuid = UUID::gen();
@@ -76,12 +75,12 @@ public:
{
WriteUnitOfWork wuow(opCtx);
std::tie(catalogId, rs) = unittest::assertGet(
- _storageEngine->getCatalog()->createCollection(opCtx, tenantNs, options, true));
+ _storageEngine->getCatalog()->createCollection(opCtx, ns, options, true));
wuow.commit();
}
std::shared_ptr<Collection> coll = std::make_shared<CollectionImpl>(
opCtx,
- tenantNs,
+ ns,
catalogId,
_storageEngine->getCatalog()->getMetaData(opCtx, catalogId),
std::move(rs));
@@ -139,9 +138,8 @@ public:
bool collectionExists(OperationContext* opCtx, const NamespaceString& nss) {
std::vector<DurableCatalog::Entry> allCollections =
_storageEngine->getCatalog()->getAllCatalogEntries(opCtx);
- TenantNamespace tenantNs(boost::none, nss);
return std::count_if(allCollections.begin(), allCollections.end(), [&](auto& entry) {
- return tenantNs == entry.tenantNs;
+ return nss == entry.nss;
});
}
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp
index 9f54c801eda..807146ed32d 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_standard_index_test.cpp
@@ -45,7 +45,6 @@
#include "mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.h"
#include "mongo/db/storage/wiredtiger/wiredtiger_session_cache.h"
#include "mongo/db/storage/wiredtiger/wiredtiger_util.h"
-#include "mongo/db/tenant_namespace.h"
#include "mongo/unittest/temp_dir.h"
#include "mongo/unittest/unittest.h"
#include "mongo/util/system_clock_source.h"
@@ -87,8 +86,7 @@ public:
<< "v" << static_cast<int>(IndexDescriptor::kLatestIndexVersion)
<< "unique" << true);
- auto collection =
- std::make_unique<CollectionMock>(TenantNamespace(boost::none, NamespaceString(ns)));
+ auto collection = std::make_unique<CollectionMock>(NamespaceString(ns));
IndexDescriptor desc("", spec);
invariant(desc.isIdIndex());
@@ -120,8 +118,7 @@ public:
spec = spec.addField(partialBSON.firstElement());
}
- auto collection =
- std::make_unique<CollectionMock>(TenantNamespace(boost::none, NamespaceString(ns)));
+ auto collection = std::make_unique<CollectionMock>(NamespaceString(ns));
IndexDescriptor& desc = _descriptors.emplace_back("", spec);