summaryrefslogtreecommitdiff
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
parent9be91a1223cd166ce515e4b6b2abd9bd604ebfbe (diff)
downloadmongo-e683ab82364fe2a9923e9035aa5eb6f8f197fbc8.tar.gz
SERVER-64606 Remove TenantNamespace
-rw-r--r--src/mongo/db/SConscript2
-rw-r--r--src/mongo/db/catalog/catalog_control.cpp1
-rw-r--r--src/mongo/db/catalog/collection.h11
-rw-r--r--src/mongo/db/catalog/collection_catalog.cpp39
-rw-r--r--src/mongo/db/catalog/collection_catalog_bm.cpp7
-rw-r--r--src/mongo/db/catalog/collection_catalog_test.cpp34
-rw-r--r--src/mongo/db/catalog/collection_impl.cpp76
-rw-r--r--src/mongo/db/catalog/collection_impl.h18
-rw-r--r--src/mongo/db/catalog/collection_mock.h24
-rw-r--r--src/mongo/db/catalog/collection_test.cpp6
-rw-r--r--src/mongo/db/catalog/collection_writer_test.cpp12
-rw-r--r--src/mongo/db/catalog/create_collection.cpp1
-rw-r--r--src/mongo/db/catalog/database_impl.cpp8
-rw-r--r--src/mongo/db/catalog/index_catalog_entry_impl.cpp4
-rw-r--r--src/mongo/db/catalog/rename_collection.cpp3
-rw-r--r--src/mongo/db/catalog/validate_state.cpp2
-rw-r--r--src/mongo/db/catalog_raii.cpp2
-rw-r--r--src/mongo/db/commands/index_filter_commands_test.cpp14
-rw-r--r--src/mongo/db/commands/list_databases.cpp1
-rw-r--r--src/mongo/db/commands/plan_cache_commands_test.cpp2
-rw-r--r--src/mongo/db/pipeline/document_source_change_stream_test.cpp48
-rw-r--r--src/mongo/db/pipeline/document_source_check_resume_token_test.cpp3
-rw-r--r--src/mongo/db/query/canonical_query_encoder_test.cpp2
-rw-r--r--src/mongo/db/query/sbe_stage_builder_test_fixture.cpp2
-rw-r--r--src/mongo/db/repair.cpp1
-rw-r--r--src/mongo/db/repl/apply_ops.cpp2
-rw-r--r--src/mongo/db/repl/rollback_impl.cpp1
-rw-r--r--src/mongo/db/repl/rollback_impl_test.cpp3
-rw-r--r--src/mongo/db/repl/storage_interface_impl.cpp1
-rw-r--r--src/mongo/db/repl/storage_timestamp_test.cpp5
-rw-r--r--src/mongo/db/repl/tenant_migration_shard_merge_util.cpp6
-rw-r--r--src/mongo/db/s/config/sharding_catalog_manager_shard_collection_test.cpp5
-rw-r--r--src/mongo/db/server_feature_flags.idl2
-rw-r--r--src/mongo/db/startup_recovery.cpp1
-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
-rw-r--r--src/mongo/db/tenant_namespace.cpp78
-rw-r--r--src/mongo/db/tenant_namespace.h149
-rw-r--r--src/mongo/db/tenant_namespace_test.cpp148
49 files changed, 306 insertions, 817 deletions
diff --git a/src/mongo/db/SConscript b/src/mongo/db/SConscript
index 7b6a56bfe8e..9d55043e9fd 100644
--- a/src/mongo/db/SConscript
+++ b/src/mongo/db/SConscript
@@ -84,7 +84,6 @@ env.Library(
target='multitenancy',
source=[
'multitenancy.cpp',
- 'tenant_namespace.cpp',
'tenant_database_name.cpp',
],
LIBDEPS=[
@@ -2660,7 +2659,6 @@ if wiredtiger:
'session_catalog_test.cpp',
'startup_warnings_mongod_test.cpp',
'tenant_database_name_test.cpp',
- 'tenant_namespace_test.cpp',
'thread_client_test.cpp',
'time_proof_service_test.cpp',
'transaction_api_test.cpp',
diff --git a/src/mongo/db/catalog/catalog_control.cpp b/src/mongo/db/catalog/catalog_control.cpp
index f52b4cd0267..510f45537a9 100644
--- a/src/mongo/db/catalog/catalog_control.cpp
+++ b/src/mongo/db/catalog/catalog_control.cpp
@@ -44,7 +44,6 @@
#include "mongo/db/namespace_string.h"
#include "mongo/db/rebuild_indexes.h"
#include "mongo/db/tenant_database_name.h"
-#include "mongo/db/tenant_namespace.h"
#include "mongo/logv2/log.h"
namespace mongo {
diff --git a/src/mongo/db/catalog/collection.h b/src/mongo/db/catalog/collection.h
index 1ebc19fcdd6..47384e3d346 100644
--- a/src/mongo/db/catalog/collection.h
+++ b/src/mongo/db/catalog/collection.h
@@ -53,7 +53,6 @@
#include "mongo/db/storage/capped_callback.h"
#include "mongo/db/storage/record_store.h"
#include "mongo/db/storage/snapshot.h"
-#include "mongo/db/tenant_namespace.h"
#include "mongo/db/yieldable.h"
#include "mongo/logv2/log_attr.h"
#include "mongo/platform/mutex.h"
@@ -198,7 +197,7 @@ public:
* only constructs an in-memory representation of what already exists on disk.
*/
virtual std::shared_ptr<Collection> make(OperationContext* opCtx,
- const TenantNamespace& tenantNs,
+ const NamespaceString& nss,
RecordId catalogId,
const CollectionOptions& options,
std::unique_ptr<RecordStore> rs) const = 0;
@@ -209,7 +208,7 @@ public:
*/
virtual std::shared_ptr<Collection> make(
OperationContext* opCtx,
- const TenantNamespace& tenantNs,
+ const NamespaceString& nss,
RecordId catalogId,
std::shared_ptr<BSONCollectionCatalogEntry::MetaData> metadata,
std::unique_ptr<RecordStore> rs) const = 0;
@@ -304,8 +303,6 @@ public:
virtual const NamespaceString& ns() const = 0;
- virtual const TenantNamespace& tenantNs() const = 0;
-
/**
* Sets a new namespace on this Collection, in the case that the Collection is being renamed.
* In general, reads and writes to Collection objects are synchronized using locks from the lock
@@ -313,9 +310,7 @@ public:
* CollectionCatalog can perform UUID to namespace lookup without holding a Collection lock. See
* CollectionCatalog::onCollectionRename().
*/
- virtual Status rename(OperationContext* opCtx,
- const TenantNamespace& tenantNs,
- bool stayTemp) = 0;
+ virtual Status rename(OperationContext* opCtx, const NamespaceString& nss, bool stayTemp) = 0;
virtual RecordId getCatalogId() const = 0;
diff --git a/src/mongo/db/catalog/collection_catalog.cpp b/src/mongo/db/catalog/collection_catalog.cpp
index 014e48b0fab..81d8f6fc616 100644
--- a/src/mongo/db/catalog/collection_catalog.cpp
+++ b/src/mongo/db/catalog/collection_catalog.cpp
@@ -371,15 +371,16 @@ public:
for (auto&& entry : entries) {
switch (entry.action) {
case UncommittedCatalogUpdates::Entry::Action::kWritableCollection:
- writeJobs.push_back(
- [collection = std::move(entry.collection)](CollectionCatalog& catalog) {
- catalog._collections[collection->ns()] = collection;
- catalog._catalog[collection->uuid()] = collection;
- auto dbIdPair =
- std::make_pair(collection->tenantNs().createTenantDatabaseName(),
- collection->uuid());
- catalog._orderedCollections[dbIdPair] = collection;
- });
+ writeJobs.push_back([collection = std::move(entry.collection)](
+ CollectionCatalog& catalog) {
+ catalog._collections[collection->ns()] = collection;
+ catalog._catalog[collection->uuid()] = collection;
+ // TODO SERVER-64608 Use tenantID from ns
+ auto dbIdPair =
+ std::make_pair(TenantDatabaseName(boost::none, collection->ns().db()),
+ collection->uuid());
+ catalog._orderedCollections[dbIdPair] = collection;
+ });
break;
case UncommittedCatalogUpdates::Entry::Action::kRenamedCollection:
writeJobs.push_back(
@@ -1345,10 +1346,11 @@ CollectionCatalog::ViewCatalogSet CollectionCatalog::getViewCatalogDbNames(
void CollectionCatalog::registerCollection(OperationContext* opCtx,
const UUID& uuid,
std::shared_ptr<Collection> coll) {
- auto tenantNs = coll->tenantNs();
- auto tenantDbName = tenantNs.createTenantDatabaseName();
+ auto nss = coll->ns();
+ // TODO SERVER-64608 Use tenantId from nss
+ auto tenantDbName = TenantDatabaseName(boost::none, nss.db());
if (NonExistenceType::kDropPending ==
- _ensureNamespaceDoesNotExist(opCtx, tenantNs.getNss(), NamespaceType::kAll)) {
+ _ensureNamespaceDoesNotExist(opCtx, nss, NamespaceType::kAll)) {
// If we have an uncommitted drop of this collection we can defer the creation, the register
// will happen in the same catalog write as the drop.
auto& uncommittedCatalogUpdates = UncommittedCatalogUpdates::get(opCtx);
@@ -1360,7 +1362,7 @@ void CollectionCatalog::registerCollection(OperationContext* opCtx,
1,
"Registering collection {namespace} with UUID {uuid}",
"Registering collection",
- logAttrs(tenantNs),
+ logAttrs(nss),
"uuid"_attr = uuid);
auto dbIdPair = std::make_pair(tenantDbName, uuid);
@@ -1370,10 +1372,10 @@ void CollectionCatalog::registerCollection(OperationContext* opCtx,
invariant(_orderedCollections.find(dbIdPair) == _orderedCollections.end());
_catalog[uuid] = coll;
- _collections[tenantNs.getNss()] = coll;
+ _collections[nss] = coll;
_orderedCollections[dbIdPair] = coll;
- if (!tenantNs.getNss().isOnInternalDb() && !tenantNs.getNss().isSystem()) {
+ if (!nss.isOnInternalDb() && !nss.isSystem()) {
_stats.userCollections += 1;
if (coll->isCapped()) {
_stats.userCapped += 1;
@@ -1391,8 +1393,8 @@ void CollectionCatalog::registerCollection(OperationContext* opCtx,
auto dbRid = ResourceId(RESOURCE_DATABASE, tenantDbName.dbName());
addResource(dbRid, tenantDbName.dbName());
- auto collRid = ResourceId(RESOURCE_COLLECTION, tenantNs.getNss().ns());
- addResource(collRid, tenantNs.getNss().ns());
+ auto collRid = ResourceId(RESOURCE_COLLECTION, nss.ns());
+ addResource(collRid, nss.ns());
}
std::shared_ptr<Collection> CollectionCatalog::deregisterCollection(OperationContext* opCtx,
@@ -1401,7 +1403,8 @@ std::shared_ptr<Collection> CollectionCatalog::deregisterCollection(OperationCon
auto coll = std::move(_catalog[uuid]);
auto ns = coll->ns();
- auto tenantDbName = coll->tenantNs().createTenantDatabaseName();
+ // TODO SERVER-64608 Use tenantID from ns
+ auto tenantDbName = TenantDatabaseName(boost::none, coll->ns().db());
auto dbIdPair = std::make_pair(tenantDbName, uuid);
LOGV2_DEBUG(20281, 1, "Deregistering collection", logAttrs(ns), "uuid"_attr = uuid);
diff --git a/src/mongo/db/catalog/collection_catalog_bm.cpp b/src/mongo/db/catalog/collection_catalog_bm.cpp
index c7a1804c747..eedb6bf1e1c 100644
--- a/src/mongo/db/catalog/collection_catalog_bm.cpp
+++ b/src/mongo/db/catalog/collection_catalog_bm.cpp
@@ -35,7 +35,6 @@
#include "mongo/db/concurrency/lock_state.h"
#include "mongo/db/operation_context.h"
#include "mongo/db/service_context.h"
-#include "mongo/db/tenant_namespace.h"
#include "mongo/util/uuid.h"
namespace mongo {
@@ -77,11 +76,9 @@ void createCollections(OperationContext* opCtx, int numCollections) {
BatchedCollectionCatalogWriter batched(opCtx);
for (auto i = 0; i < numCollections; i++) {
- const TenantNamespace tenantNs(boost::none,
- NamespaceString("collection_catalog_bm", std::to_string(i)));
+ const NamespaceString nss("collection_catalog_bm", std::to_string(i));
CollectionCatalog::write(opCtx, [&](CollectionCatalog& catalog) {
- catalog.registerCollection(
- opCtx, UUID::gen(), std::make_shared<CollectionMock>(tenantNs));
+ catalog.registerCollection(opCtx, UUID::gen(), std::make_shared<CollectionMock>(nss));
});
}
}
diff --git a/src/mongo/db/catalog/collection_catalog_test.cpp b/src/mongo/db/catalog/collection_catalog_test.cpp
index db498e2aa6d..82e67d758b6 100644
--- a/src/mongo/db/catalog/collection_catalog_test.cpp
+++ b/src/mongo/db/catalog/collection_catalog_test.cpp
@@ -68,8 +68,7 @@ public:
ServiceContextMongoDTest::setUp();
opCtx = makeOperationContext();
- std::shared_ptr<Collection> collection =
- std::make_shared<CollectionMock>(TenantNamespace(boost::none, nss));
+ std::shared_ptr<Collection> collection = std::make_shared<CollectionMock>(nss);
col = CollectionPtr(collection.get(), CollectionPtr::NoYieldTag{});
// Register dummy collection in catalog.
catalog.registerCollection(opCtx.get(), colUUID, std::move(collection));
@@ -93,12 +92,10 @@ public:
NamespaceString barNss("bar", "coll" + std::to_string(counter));
auto fooUuid = UUID::gen();
- std::shared_ptr<Collection> fooColl =
- std::make_shared<CollectionMock>(TenantNamespace(boost::none, fooNss));
+ std::shared_ptr<Collection> fooColl = std::make_shared<CollectionMock>(fooNss);
auto barUuid = UUID::gen();
- std::shared_ptr<Collection> barColl =
- std::make_shared<CollectionMock>(TenantNamespace(boost::none, barNss));
+ std::shared_ptr<Collection> barColl = std::make_shared<CollectionMock>(barNss);
dbMap["foo"].insert(std::make_pair(fooUuid, fooColl.get()));
dbMap["bar"].insert(std::make_pair(barUuid, barColl.get()));
@@ -279,8 +276,7 @@ public:
void setUp() {
for (int i = 0; i < 5; i++) {
NamespaceString nss("resourceDb", "coll" + std::to_string(i));
- std::shared_ptr<Collection> collection =
- std::make_shared<CollectionMock>(TenantNamespace(boost::none, nss));
+ std::shared_ptr<Collection> collection = std::make_shared<CollectionMock>(nss);
auto uuid = collection->uuid();
catalog.registerCollection(&opCtx, uuid, std::move(collection));
@@ -429,8 +425,7 @@ TEST_F(CollectionCatalogTest, LookupNSSByUUID) {
TEST_F(CollectionCatalogTest, InsertAfterLookup) {
auto newUUID = UUID::gen();
NamespaceString newNss(nss.db(), "newcol");
- std::shared_ptr<Collection> newCollShared =
- std::make_shared<CollectionMock>(TenantNamespace(boost::none, newNss));
+ std::shared_ptr<Collection> newCollShared = std::make_shared<CollectionMock>(newNss);
auto newCol = newCollShared.get();
// Ensure that looking up non-existing UUIDs doesn't affect later registration of those UUIDs.
@@ -450,15 +445,14 @@ TEST_F(CollectionCatalogTest, OnDropCollection) {
TEST_F(CollectionCatalogTest, RenameCollection) {
auto uuid = UUID::gen();
NamespaceString oldNss(nss.db(), "oldcol");
- std::shared_ptr<Collection> collShared =
- std::make_shared<CollectionMock>(TenantNamespace(boost::none, oldNss));
+ std::shared_ptr<Collection> collShared = std::make_shared<CollectionMock>(oldNss);
auto collection = collShared.get();
catalog.registerCollection(opCtx.get(), uuid, std::move(collShared));
ASSERT_EQUALS(catalog.lookupCollectionByUUID(opCtx.get(), uuid), collection);
- TenantNamespace newNss(boost::none, NamespaceString(nss.db(), "newcol"));
+ NamespaceString newNss(NamespaceString(nss.db(), "newcol"));
ASSERT_OK(collection->rename(opCtx.get(), newNss, false));
- ASSERT_EQ(collection->ns(), newNss.getNss());
+ ASSERT_EQ(collection->ns(), newNss);
ASSERT_EQUALS(catalog.lookupCollectionByUUID(opCtx.get(), uuid), collection);
}
@@ -483,8 +477,7 @@ TEST_F(CollectionCatalogTest, LookupNSSByUUIDForClosedCatalogReturnsOldNSSIfDrop
TEST_F(CollectionCatalogTest, LookupNSSByUUIDForClosedCatalogReturnsNewlyCreatedNSS) {
auto newUUID = UUID::gen();
NamespaceString newNss(nss.db(), "newcol");
- std::shared_ptr<Collection> newCollShared =
- std::make_shared<CollectionMock>(TenantNamespace(boost::none, newNss));
+ std::shared_ptr<Collection> newCollShared = std::make_shared<CollectionMock>(newNss);
auto newCol = newCollShared.get();
// Ensure that looking up non-existing UUIDs doesn't affect later registration of those UUIDs.
@@ -511,8 +504,7 @@ TEST_F(CollectionCatalogTest, LookupNSSByUUIDForClosedCatalogReturnsNewlyCreated
TEST_F(CollectionCatalogTest, LookupNSSByUUIDForClosedCatalogReturnsFreshestNSS) {
NamespaceString newNss(nss.db(), "newcol");
- std::shared_ptr<Collection> newCollShared =
- std::make_shared<CollectionMock>(TenantNamespace(boost::none, newNss));
+ std::shared_ptr<Collection> newCollShared = std::make_shared<CollectionMock>(newNss);
auto newCol = newCollShared.get();
{
@@ -567,8 +559,7 @@ TEST_F(CollectionCatalogTest, GetAllCollectionNamesAndGetAllDbNames) {
std::vector<NamespaceString> nsss = {aColl, b1Coll, b2Coll, cColl, d1Coll, d2Coll, d3Coll};
for (auto& nss : nsss) {
- std::shared_ptr<Collection> newColl =
- std::make_shared<CollectionMock>(TenantNamespace(boost::none, nss));
+ std::shared_ptr<Collection> newColl = std::make_shared<CollectionMock>(nss);
auto uuid = UUID::gen();
catalog.registerCollection(opCtx.get(), uuid, std::move(newColl));
}
@@ -624,8 +615,7 @@ TEST_F(CollectionCatalogTest, GetAllCollectionNamesAndGetAllDbNamesWithUncommitt
std::vector<NamespaceString> nsss = {aColl, b1Coll, b2Coll, cColl, d1Coll, d2Coll, d3Coll};
for (auto& nss : nsss) {
- std::shared_ptr<Collection> newColl =
- std::make_shared<CollectionMock>(TenantNamespace(boost::none, nss));
+ std::shared_ptr<Collection> newColl = std::make_shared<CollectionMock>(nss);
auto uuid = UUID::gen();
catalog.registerCollection(opCtx.get(), uuid, std::move(newColl));
}
diff --git a/src/mongo/db/catalog/collection_impl.cpp b/src/mongo/db/catalog/collection_impl.cpp
index 874a2c08873..a730614aab3 100644
--- a/src/mongo/db/catalog/collection_impl.cpp
+++ b/src/mongo/db/catalog/collection_impl.cpp
@@ -151,7 +151,7 @@ Status checkFailCollectionInsertsFailPoint(const NamespaceString& ns, const BSON
// CollatorInterface. Returns null if the BSONObj is empty. We expect the stored collation to be
// valid, since it gets validated on collection create.
std::unique_ptr<CollatorInterface> parseCollation(OperationContext* opCtx,
- const TenantNamespace& tenantNs,
+ const NamespaceString& nss,
BSONObj collationSpec) {
if (collationSpec.isEmpty()) {
return {nullptr};
@@ -168,7 +168,7 @@ std::unique_ptr<CollatorInterface> parseCollation(OperationContext* opCtx,
"Collection {namespace} has a default collation which is incompatible with this "
"version: {collationSpec}"
"Collection has a default collation incompatible with this version",
- logAttrs(tenantNs),
+ logAttrs(nss),
"collationSpec"_attr = collationSpec);
fassertFailedNoTrace(40144);
}
@@ -412,22 +412,22 @@ void CollectionImpl::SharedState::instanceDeleted(CollectionImpl* collection) {
}
CollectionImpl::CollectionImpl(OperationContext* opCtx,
- const TenantNamespace& tenantNs,
+ const NamespaceString& nss,
RecordId catalogId,
const CollectionOptions& options,
std::unique_ptr<RecordStore> recordStore)
- : _tenantNs(tenantNs),
+ : _ns(nss),
_catalogId(catalogId),
_uuid(options.uuid.get()),
_shared(std::make_shared<SharedState>(this, std::move(recordStore), options)),
_indexCatalog(std::make_unique<IndexCatalogImpl>()) {}
CollectionImpl::CollectionImpl(OperationContext* opCtx,
- const TenantNamespace& tenantNs,
+ const NamespaceString& nss,
RecordId catalogId,
std::shared_ptr<BSONCollectionCatalogEntry::MetaData> metadata,
std::unique_ptr<RecordStore> recordStore)
- : CollectionImpl(opCtx, tenantNs, catalogId, metadata->options, std::move(recordStore)) {
+ : CollectionImpl(opCtx, nss, catalogId, metadata->options, std::move(recordStore)) {
_metadata = std::move(metadata);
}
@@ -443,21 +443,21 @@ void CollectionImpl::onDeregisterFromCatalog(OperationContext* opCtx) {
std::shared_ptr<Collection> CollectionImpl::FactoryImpl::make(
OperationContext* opCtx,
- const TenantNamespace& tenantNs,
+ const NamespaceString& nss,
RecordId catalogId,
const CollectionOptions& options,
std::unique_ptr<RecordStore> rs) const {
- return std::make_shared<CollectionImpl>(opCtx, tenantNs, catalogId, options, std::move(rs));
+ return std::make_shared<CollectionImpl>(opCtx, nss, catalogId, options, std::move(rs));
}
std::shared_ptr<Collection> CollectionImpl::FactoryImpl::make(
OperationContext* opCtx,
- const TenantNamespace& tenantNs,
+ const NamespaceString& nss,
RecordId catalogId,
std::shared_ptr<BSONCollectionCatalogEntry::MetaData> metadata,
std::unique_ptr<RecordStore> rs) const {
return std::make_shared<CollectionImpl>(
- opCtx, tenantNs, catalogId, std::move(metadata), std::move(rs));
+ opCtx, nss, catalogId, std::move(metadata), std::move(rs));
}
std::shared_ptr<Collection> CollectionImpl::clone() const {
@@ -476,7 +476,7 @@ void CollectionImpl::init(OperationContext* opCtx) {
_metadata = DurableCatalog::get(opCtx)->getMetaData(opCtx, getCatalogId());
const auto& collectionOptions = _metadata->options;
- _shared->_collator = parseCollation(opCtx, _tenantNs, collectionOptions.collation);
+ _shared->_collator = parseCollation(opCtx, _ns, collectionOptions.collation);
auto validatorDoc = collectionOptions.validator.getOwned();
// Enforce that the validator can be used on this namespace.
@@ -485,11 +485,11 @@ void CollectionImpl::init(OperationContext* opCtx) {
// Make sure to copy the action and level before parsing MatchExpression, since certain features
// are not supported with certain combinations of action and level.
if (collectionOptions.recordPreImages) {
- uassertStatusOK(validateRecordPreImagesOptionIsPermitted(_tenantNs.getNss()));
+ uassertStatusOK(validateRecordPreImagesOptionIsPermitted(_ns));
}
if (collectionOptions.changeStreamPreAndPostImagesOptions.getEnabled()) {
- uassertStatusOK(validateChangeStreamPreAndPostImagesOptionIsPermitted(_tenantNs.getNss()));
+ uassertStatusOK(validateChangeStreamPreAndPostImagesOptionIsPermitted(_ns));
}
// Store the result (OK / error) of parsing the validator, but do not enforce that the result is
@@ -503,7 +503,7 @@ void CollectionImpl::init(OperationContext* opCtx) {
{logv2::LogTag::kStartupWarnings},
"Collection {namespace} has malformed validator: {validatorStatus}",
"Collection has malformed validator",
- logAttrs(_tenantNs),
+ logAttrs(_ns),
"validatorStatus"_attr = _validator.getStatus());
}
@@ -550,7 +550,7 @@ void CollectionImpl::setCommitted(bool val) {
}
bool CollectionImpl::requiresIdIndex() const {
- if (_tenantNs.getNss().isOplog()) {
+ if (_ns.isOplog()) {
// No indexes on the oplog.
return false;
}
@@ -560,9 +560,8 @@ bool CollectionImpl::requiresIdIndex() const {
return false;
}
- if (_tenantNs.getNss().isSystem()) {
- StringData shortName =
- _tenantNs.getNss().coll().substr(_tenantNs.getNss().coll().find('.') + 1);
+ if (_ns.isSystem()) {
+ StringData shortName = _ns.coll().substr(_ns.coll().find('.') + 1);
if (shortName == "indexes" || shortName == "namespaces" || shortName == "profile") {
return false;
}
@@ -802,8 +801,7 @@ Status CollectionImpl::insertDocuments(OperationContext* opCtx,
OpDebug* opDebug,
bool fromMigrate) const {
- auto status = checkFailCollectionInsertsFailPoint(_tenantNs.getNss(),
- (begin != end ? begin->doc : BSONObj()));
+ auto status = checkFailCollectionInsertsFailPoint(_ns, (begin != end ? begin->doc : BSONObj()));
if (!status.isOK()) {
return status;
}
@@ -815,8 +813,8 @@ Status CollectionImpl::insertDocuments(OperationContext* opCtx,
if (hasIdIndex && it->doc["_id"].eoo()) {
return Status(ErrorCodes::InternalError,
str::stream()
- << "Collection::insertDocument got document without _id for tenantNs:"
- << _tenantNs.toString());
+ << "Collection::insertDocument got document without _id for ns:"
+ << _ns.toString());
}
auto status = _checkValidationAndParseResult(opCtx, it->doc);
@@ -846,7 +844,7 @@ Status CollectionImpl::insertDocuments(OperationContext* opCtx,
LOGV2(20289,
"hangAfterCollectionInserts fail point enabled. Blocking "
"until fail point is disabled.",
- "tenantNs"_attr = _tenantNs,
+ "ns"_attr = _ns,
"whenFirst"_attr = whenFirst);
hangAfterCollectionInserts.pauseWhileSet(opCtx);
},
@@ -854,7 +852,7 @@ Status CollectionImpl::insertDocuments(OperationContext* opCtx,
const auto& collElem = data["collectionNS"];
const auto& firstIdElem = data["first_id"];
// If the failpoint specifies no collection or matches the existing one, hang.
- return (!collElem || _tenantNs.getNss().ns() == collElem.str()) &&
+ return (!collElem || _ns.ns() == collElem.str()) &&
(!firstIdElem ||
(begin != end && firstIdElem.type() == mongo::String &&
begin->doc["_id"].str() == firstIdElem.str()));
@@ -875,7 +873,7 @@ Status CollectionImpl::insertDocument(OperationContext* opCtx,
Status CollectionImpl::insertDocumentForBulkLoader(
OperationContext* opCtx, const BSONObj& doc, const OnRecordInsertedFn& onRecordInserted) const {
- auto status = checkFailCollectionInsertsFailPoint(_tenantNs.getNss(), doc);
+ auto status = checkFailCollectionInsertsFailPoint(_ns, doc);
if (!status.isOK()) {
return status;
}
@@ -908,7 +906,7 @@ Status CollectionImpl::insertDocumentForBulkLoader(
LOGV2(20290,
"Failpoint failAfterBulkLoadDocInsert enabled. Throwing "
"WriteConflictException",
- logAttrs(_tenantNs));
+ logAttrs(_ns));
throw WriteConflictException();
}
@@ -916,7 +914,7 @@ Status CollectionImpl::insertDocumentForBulkLoader(
OplogSlot slot;
// Fetch a new optime now, if necessary.
auto replCoord = repl::ReplicationCoordinator::get(opCtx);
- if (!replCoord->isOplogDisabledFor(opCtx, _tenantNs.getNss())) {
+ if (!replCoord->isOplogDisabledFor(opCtx, _ns)) {
// Populate 'slot' with a new optime.
slot = repl::getNextOpTime(opCtx);
}
@@ -960,7 +958,7 @@ Status CollectionImpl::_insertDocuments(OperationContext* opCtx,
// increasing cluster key natively guarantee preservation of the insertion order, and don't
// need serialisation. We allow concurrent inserts for clustered capped collections.
Lock::ResourceLock heldUntilEndOfWUOW{
- opCtx->lockState(), ResourceId(RESOURCE_METADATA, _tenantNs.getNss().ns()), MODE_X};
+ opCtx->lockState(), ResourceId(RESOURCE_METADATA, _ns.ns()), MODE_X};
}
std::vector<Record> records;
@@ -1082,8 +1080,8 @@ void CollectionImpl::_cappedDeleteAsNeeded(OperationContext* opCtx,
// '_cappedFirstRecord' until the outermost WriteUnitOfWork commits or aborts. Locking the
// metadata resource exclusively on the collection gives us that guarantee as it uses
// two-phase locking semantics.
- invariant(opCtx->lockState()->getLockMode(
- ResourceId(RESOURCE_METADATA, _tenantNs.getNss().ns())) == MODE_X);
+ invariant(opCtx->lockState()->getLockMode(ResourceId(RESOURCE_METADATA, _ns.ns())) ==
+ MODE_X);
} else {
// Capped deletes not performed under the capped lock need the '_cappedFirstRecordMutex'
// mutex.
@@ -1347,7 +1345,7 @@ RecordId CollectionImpl::updateDocument(OperationContext* opCtx,
// '_cappedFirstRecord'.
// See SERVER-21646.
Lock::ResourceLock heldUntilEndOfWUOW{
- opCtx->lockState(), ResourceId(RESOURCE_METADATA, _tenantNs.getNss().ns()), MODE_X};
+ opCtx->lockState(), ResourceId(RESOURCE_METADATA, _ns.ns()), MODE_X};
}
SnapshotId sid = opCtx->recoveryUnit()->getSnapshotId();
@@ -1607,7 +1605,7 @@ bool CollectionImpl::getRecordPreImages() const {
void CollectionImpl::setRecordPreImages(OperationContext* opCtx, bool val) {
if (val) {
- uassertStatusOK(validateRecordPreImagesOptionIsPermitted(_tenantNs.getNss()));
+ uassertStatusOK(validateRecordPreImagesOptionIsPermitted(_ns));
}
_writeMetadata(
@@ -1621,7 +1619,7 @@ bool CollectionImpl::isChangeStreamPreAndPostImagesEnabled() const {
void CollectionImpl::setChangeStreamPreAndPostImages(OperationContext* opCtx,
ChangeStreamPreAndPostImagesOptions val) {
if (val.getEnabled()) {
- uassertStatusOK(validateChangeStreamPreAndPostImagesOptionIsPermitted(_tenantNs.getNss()));
+ uassertStatusOK(validateChangeStreamPreAndPostImagesOptionIsPermitted(_ns));
}
_writeMetadata(opCtx, [&](BSONCollectionCatalogEntry::MetaData& md) {
@@ -1963,22 +1961,20 @@ std::unique_ptr<PlanExecutor, PlanExecutor::Deleter> CollectionImpl::makePlanExe
opCtx, &yieldableCollection, yieldPolicy, direction, resumeAfterRecordId);
}
-Status CollectionImpl::rename(OperationContext* opCtx,
- const TenantNamespace& tenantNs,
- bool stayTemp) {
+Status CollectionImpl::rename(OperationContext* opCtx, const NamespaceString& nss, bool stayTemp) {
auto metadata = std::make_shared<BSONCollectionCatalogEntry::MetaData>(*_metadata);
- metadata->tenantNs = tenantNs;
+ metadata->ns = nss.ns();
if (!stayTemp)
metadata->options.temp = false;
Status status =
- DurableCatalog::get(opCtx)->renameCollection(opCtx, getCatalogId(), tenantNs, *metadata);
+ DurableCatalog::get(opCtx)->renameCollection(opCtx, getCatalogId(), nss, *metadata);
if (!status.isOK()) {
return status;
}
_metadata = std::move(metadata);
- _tenantNs = std::move(tenantNs);
- _shared->_recordStore.get()->setNs(_tenantNs.getNss());
+ _ns = std::move(nss);
+ _shared->_recordStore.get()->setNs(_ns);
return status;
}
diff --git a/src/mongo/db/catalog/collection_impl.h b/src/mongo/db/catalog/collection_impl.h
index f18e91501ab..e763250c6b4 100644
--- a/src/mongo/db/catalog/collection_impl.h
+++ b/src/mongo/db/catalog/collection_impl.h
@@ -43,13 +43,13 @@ class CollectionImpl final : public Collection {
public:
// TODO SERVER-56999: We should just need one API to create Collections
explicit CollectionImpl(OperationContext* opCtx,
- const TenantNamespace& tenantNs,
+ const NamespaceString& nss,
RecordId catalogId,
const CollectionOptions& options,
std::unique_ptr<RecordStore> recordStore);
explicit CollectionImpl(OperationContext* opCtx,
- const TenantNamespace& tenantNs,
+ const NamespaceString& nss,
RecordId catalogId,
std::shared_ptr<BSONCollectionCatalogEntry::MetaData> metadata,
std::unique_ptr<RecordStore> recordStore);
@@ -62,14 +62,14 @@ public:
public:
// TODO SERVER-56999: We should just need one API to create Collections
std::shared_ptr<Collection> make(OperationContext* opCtx,
- const TenantNamespace& tenantNs,
+ const NamespaceString& nss,
RecordId catalogId,
const CollectionOptions& options,
std::unique_ptr<RecordStore> rs) const final;
std::shared_ptr<Collection> make(
OperationContext* opCtx,
- const TenantNamespace& tenantNs,
+ const NamespaceString& nss,
RecordId catalogId,
std::shared_ptr<BSONCollectionCatalogEntry::MetaData> metadata,
std::unique_ptr<RecordStore> rs) const final;
@@ -83,14 +83,10 @@ public:
void setCommitted(bool val) final;
const NamespaceString& ns() const final {
- return _tenantNs.getNss();
+ return _ns;
}
- const TenantNamespace& tenantNs() const final {
- return _tenantNs;
- }
-
- Status rename(OperationContext* opCtx, const TenantNamespace& tenantNs, bool stayTemp) final;
+ Status rename(OperationContext* opCtx, const NamespaceString& nss, bool stayTemp) final;
RecordId getCatalogId() const final {
return _catalogId;
@@ -594,7 +590,7 @@ private:
RecordId _cappedFirstRecord;
};
- TenantNamespace _tenantNs;
+ NamespaceString _ns;
RecordId _catalogId;
UUID _uuid;
bool _cachedCommitted = true;
diff --git a/src/mongo/db/catalog/collection_mock.h b/src/mongo/db/catalog/collection_mock.h
index 5f2f0ca8680..46fb5ac47d3 100644
--- a/src/mongo/db/catalog/collection_mock.h
+++ b/src/mongo/db/catalog/collection_mock.h
@@ -40,12 +40,12 @@ namespace mongo {
*/
class CollectionMock : public Collection {
public:
- CollectionMock(const TenantNamespace& tenantNs)
- : CollectionMock(tenantNs, std::unique_ptr<IndexCatalog>()) {}
- CollectionMock(const TenantNamespace& tenantNs, std::unique_ptr<IndexCatalog> indexCatalog)
- : _tenantNs(tenantNs), _indexCatalog(std::move(indexCatalog)) {}
- CollectionMock(const TenantNamespace& tenantNs, RecordId catalogId)
- : _tenantNs(tenantNs), _catalogId(catalogId) {}
+ CollectionMock(const NamespaceString& nss)
+ : CollectionMock(nss, std::unique_ptr<IndexCatalog>()) {}
+ CollectionMock(const NamespaceString& nss, std::unique_ptr<IndexCatalog> indexCatalog)
+ : _nss(nss), _indexCatalog(std::move(indexCatalog)) {}
+ CollectionMock(const NamespaceString& nss, RecordId catalogId)
+ : _nss(nss), _catalogId(catalogId) {}
~CollectionMock() = default;
std::shared_ptr<Collection> clone() const {
@@ -70,15 +70,11 @@ public:
}
const NamespaceString& ns() const {
- return _tenantNs.getNss();
+ return _nss;
}
- const TenantNamespace& tenantNs() const {
- return _tenantNs;
- }
-
- Status rename(OperationContext* opCtx, const TenantNamespace& tenantNs, bool stayTemp) final {
- _tenantNs = std::move(tenantNs);
+ Status rename(OperationContext* opCtx, const NamespaceString& nss, bool stayTemp) final {
+ _nss = std::move(nss);
return Status::OK();
}
@@ -501,7 +497,7 @@ public:
private:
UUID _uuid = UUID::gen();
- TenantNamespace _tenantNs;
+ NamespaceString _nss;
RecordId _catalogId{0};
clonable_ptr<IndexCatalog> _indexCatalog;
bool _committed = true;
diff --git a/src/mongo/db/catalog/collection_test.cpp b/src/mongo/db/catalog/collection_test.cpp
index 710249b5c0c..759a01fcd52 100644
--- a/src/mongo/db/catalog/collection_test.cpp
+++ b/src/mongo/db/catalog/collection_test.cpp
@@ -462,7 +462,7 @@ TEST_F(CollectionTest, CheckTimeseriesBucketDocsForMixedSchemaData) {
}
TEST_F(CatalogTestFixture, CollectionPtrNoYieldTag) {
- CollectionMock mock(TenantNamespace(boost::none, NamespaceString("test.t")));
+ CollectionMock mock(NamespaceString("test.t"));
CollectionPtr coll(&mock, CollectionPtr::NoYieldTag{});
ASSERT_TRUE(coll);
@@ -483,8 +483,8 @@ TEST_F(CatalogTestFixture, CollectionPtrNoYieldTag) {
}
TEST_F(CatalogTestFixture, CollectionPtrYieldable) {
- CollectionMock beforeYield(TenantNamespace(boost::none, NamespaceString("test.t")));
- CollectionMock afterYield(TenantNamespace(boost::none, NamespaceString("test.t")));
+ CollectionMock beforeYield(NamespaceString("test.t"));
+ CollectionMock afterYield(NamespaceString("test.t"));
int numRestoreCalls = 0;
diff --git a/src/mongo/db/catalog/collection_writer_test.cpp b/src/mongo/db/catalog/collection_writer_test.cpp
index 8e32876307b..13214b1f738 100644
--- a/src/mongo/db/catalog/collection_writer_test.cpp
+++ b/src/mongo/db/catalog/collection_writer_test.cpp
@@ -56,8 +56,7 @@ protected:
void setUp() override {
CatalogTestFixture::setUp();
- std::shared_ptr<Collection> collection =
- std::make_shared<CollectionMock>(TenantNamespace(boost::none, kNss));
+ std::shared_ptr<Collection> collection = std::make_shared<CollectionMock>(kNss);
CollectionCatalog::write(getServiceContext(), [&](CollectionCatalog& catalog) {
catalog.registerCollection(operationContext(), UUID::gen(), std::move(collection));
});
@@ -267,11 +266,10 @@ public:
CollectionCatalog::write(getServiceContext(), [&](CollectionCatalog& catalog) {
for (size_t i = 0; i < NumCollections; ++i) {
- catalog.registerCollection(
- operationContext(),
- UUID::gen(),
- std::make_shared<CollectionMock>(TenantNamespace(
- boost::none, NamespaceString("many", fmt::format("coll{}", i)))));
+ catalog.registerCollection(operationContext(),
+ UUID::gen(),
+ std::make_shared<CollectionMock>(
+ NamespaceString("many", fmt::format("coll{}", i))));
}
});
}
diff --git a/src/mongo/db/catalog/create_collection.cpp b/src/mongo/db/catalog/create_collection.cpp
index fe85b92719c..74be2bd73e4 100644
--- a/src/mongo/db/catalog/create_collection.cpp
+++ b/src/mongo/db/catalog/create_collection.cpp
@@ -57,7 +57,6 @@
#include "mongo/db/repl/replication_coordinator.h"
#include "mongo/db/storage/storage_parameters_gen.h"
#include "mongo/db/tenant_database_name.h"
-#include "mongo/db/tenant_namespace.h"
#include "mongo/db/timeseries/timeseries_options.h"
#include "mongo/idl/command_generic_argument.h"
#include "mongo/logv2/log.h"
diff --git a/src/mongo/db/catalog/database_impl.cpp b/src/mongo/db/catalog/database_impl.cpp
index 58990585692..76371a65f80 100644
--- a/src/mongo/db/catalog/database_impl.cpp
+++ b/src/mongo/db/catalog/database_impl.cpp
@@ -696,8 +696,7 @@ Status DatabaseImpl::renameCollection(OperationContext* opCtx,
// because the CollectionCatalog manages the necessary isolation for this Collection until the
// WUOW commits.
auto writableCollection = collToRename.getWritableCollection();
- TenantNamespace toTenantNs(boost::none, toNss);
- Status status = writableCollection->rename(opCtx, toTenantNs, stayTemp);
+ Status status = writableCollection->rename(opCtx, toNss, stayTemp);
if (!status.isOK())
return status;
@@ -855,13 +854,12 @@ Collection* DatabaseImpl::createCollection(OperationContext* opCtx,
// Create Collection object
auto storageEngine = opCtx->getServiceContext()->getStorageEngine();
- TenantNamespace tenantNs(boost::none, nss);
std::pair<RecordId, std::unique_ptr<RecordStore>> catalogIdRecordStorePair =
uassertStatusOK(storageEngine->getCatalog()->createCollection(
- opCtx, tenantNs, optionsWithUUID, true /*allocateDefaultSpace*/));
+ opCtx, nss, optionsWithUUID, true /*allocateDefaultSpace*/));
auto catalogId = catalogIdRecordStorePair.first;
std::shared_ptr<Collection> ownedCollection = Collection::Factory::get(opCtx)->make(
- opCtx, tenantNs, catalogId, optionsWithUUID, std::move(catalogIdRecordStorePair.second));
+ opCtx, nss, catalogId, optionsWithUUID, std::move(catalogIdRecordStorePair.second));
auto collection = ownedCollection.get();
ownedCollection->init(opCtx);
ownedCollection->setCommitted(false);
diff --git a/src/mongo/db/catalog/index_catalog_entry_impl.cpp b/src/mongo/db/catalog/index_catalog_entry_impl.cpp
index 8936da74bca..d7ab018fabc 100644
--- a/src/mongo/db/catalog/index_catalog_entry_impl.cpp
+++ b/src/mongo/db/catalog/index_catalog_entry_impl.cpp
@@ -79,7 +79,7 @@ IndexCatalogEntryImpl::IndexCatalogEntryImpl(OperationContext* const opCtx,
_descriptor->_entry = this;
_isReady = collection->isIndexReady(_descriptor->indexName());
- auto nss = DurableCatalog::get(opCtx)->getEntry(_catalogId).tenantNs.getNss();
+ auto nss = DurableCatalog::get(opCtx)->getEntry(_catalogId).nss;
const BSONObj& collation = _descriptor->collation();
if (!collation.isEmpty()) {
auto statusWithCollator =
@@ -351,7 +351,7 @@ std::shared_ptr<Ident> IndexCatalogEntryImpl::getSharedIdent() const {
// ----
NamespaceString IndexCatalogEntryImpl::getNSSFromCatalog(OperationContext* opCtx) const {
- return DurableCatalog::get(opCtx)->getEntry(_catalogId).tenantNs.getNss();
+ return DurableCatalog::get(opCtx)->getEntry(_catalogId).nss;
}
bool IndexCatalogEntryImpl::isReadyInMySnapshot(OperationContext* opCtx) const {
diff --git a/src/mongo/db/catalog/rename_collection.cpp b/src/mongo/db/catalog/rename_collection.cpp
index 70cc4fe307e..d9aab7b34ae 100644
--- a/src/mongo/db/catalog/rename_collection.cpp
+++ b/src/mongo/db/catalog/rename_collection.cpp
@@ -98,8 +98,7 @@ Status checkSourceAndTargetNamespaces(OperationContext* opCtx,
return {ErrorCodes::IllegalOperation,
"Cannot rename collections between a replicated and an unreplicated database"};
- // TODO SERVER-63105 Make renameCollection accept TenantNamespace and create tenantDbName with
- // the right tenant instead boost::none.
+ // TODO SERVER-64608 Use the tenantID from 'source' to construct the DatabaseName
const TenantDatabaseName tenantDbName(boost::none, source.db());
auto db = DatabaseHolder::get(opCtx)->getDb(opCtx, tenantDbName);
if (!db || db->isDropPending(opCtx))
diff --git a/src/mongo/db/catalog/validate_state.cpp b/src/mongo/db/catalog/validate_state.cpp
index d5d5a322503..434950b9540 100644
--- a/src/mongo/db/catalog/validate_state.cpp
+++ b/src/mongo/db/catalog/validate_state.cpp
@@ -282,7 +282,7 @@ void ValidateState::_relockDatabaseAndCollection(OperationContext* opCtx) {
<< " while validating collection: " << _nss << " (" << *_uuid << ")";
_databaseLock.emplace(opCtx, _nss.db(), MODE_IS);
- // TODO SERVER-63106 Have the ValidateState implementation use TenantNamespace
+ // TODO SERVER-64608 Use the tenantID from '_nss' to construct the DatabaseName
const TenantDatabaseName tenantDbName(boost::none, _nss.db());
_database = DatabaseHolder::get(opCtx)->getDb(opCtx, tenantDbName);
uassert(ErrorCodes::Interrupted, dbErrMsg, _database);
diff --git a/src/mongo/db/catalog_raii.cpp b/src/mongo/db/catalog_raii.cpp
index d5a49c92c99..3280e0bc0ac 100644
--- a/src/mongo/db/catalog_raii.cpp
+++ b/src/mongo/db/catalog_raii.cpp
@@ -265,7 +265,7 @@ AutoGetCollection::AutoGetCollection(
auto secondaryResolvedNss =
catalog->resolveNamespaceStringOrUUID(opCtx, secondaryNssOrUUID);
auto secondaryColl = catalog->lookupCollectionByNamespace(opCtx, secondaryResolvedNss);
- // TODO SERVER-62926 Change collection lock RAII types to use TenantNamespace
+ // TODO SERVER-64608 Use tenantID on NamespaceString to construct DatabaseName
const TenantDatabaseName secondaryTenantDbName(boost::none, secondaryNssOrUUID.db());
verifyDbAndCollection(opCtx,
MODE_IS,
diff --git a/src/mongo/db/commands/index_filter_commands_test.cpp b/src/mongo/db/commands/index_filter_commands_test.cpp
index 5cea275b5a8..cc8cc32bf4a 100644
--- a/src/mongo/db/commands/index_filter_commands_test.cpp
+++ b/src/mongo/db/commands/index_filter_commands_test.cpp
@@ -57,7 +57,7 @@ using std::vector;
static const NamespaceString nss("test.collection");
PlanCacheKey makeKey(const CanonicalQuery& cq) {
- CollectionMock coll(TenantNamespace(boost::none, nss));
+ CollectionMock coll(nss);
return plan_cache_key_factory::make<PlanCacheKey>(cq, &coll);
}
@@ -229,7 +229,7 @@ TEST(IndexFilterCommandsTest, ClearFiltersInvalidParameter) {
QuerySettings empty;
PlanCache planCache(5000);
OperationContextNoop opCtx;
- CollectionMock coll(TenantNamespace(boost::none, nss));
+ CollectionMock coll(nss);
// If present, query has to be an object.
ASSERT_NOT_OK(
@@ -255,7 +255,7 @@ TEST(IndexFilterCommandsTest, ClearNonexistentHint) {
QuerySettings querySettings;
PlanCache planCache(5000);
OperationContextNoop opCtx;
- CollectionMock coll(TenantNamespace(boost::none, nss));
+ CollectionMock coll(nss);
ASSERT_OK(SetFilter::set(
&opCtx, &coll, &querySettings, &planCache, fromjson("{query: {a: 1}, indexes: [{a: 1}]}")));
@@ -278,7 +278,7 @@ TEST(IndexFilterCommandsTest, SetFilterInvalidParameter) {
QuerySettings empty;
PlanCache planCache(5000);
OperationContextNoop opCtx;
- CollectionMock coll(TenantNamespace(boost::none, nss));
+ CollectionMock coll(nss);
ASSERT_NOT_OK(SetFilter::set(&opCtx, &coll, &empty, &planCache, fromjson("{}")));
// Missing required query field.
@@ -336,7 +336,7 @@ TEST(IndexFilterCommandsTest, SetAndClearFilters) {
PlanCache planCache(5000);
QueryTestServiceContext serviceContext;
auto opCtx = serviceContext.makeOperationContext();
- CollectionMock coll(TenantNamespace(boost::none, nss));
+ CollectionMock coll(nss);
// Inject query shape into plan cache.
addQueryShapeToPlanCache(opCtx.get(),
@@ -439,7 +439,7 @@ TEST(IndexFilterCommandsTest, SetAndClearFiltersCollation) {
QueryTestServiceContext serviceContext;
auto opCtx = serviceContext.makeOperationContext();
QuerySettings querySettings;
- CollectionMock coll(TenantNamespace(boost::none, nss));
+ CollectionMock coll(nss);
PlanCache planCache(5000);
// Inject query shapes with and without collation into plan cache.
@@ -511,7 +511,7 @@ TEST(IndexFilterCommandsTest, SetFilterAcceptsIndexNames) {
QueryTestServiceContext serviceContext;
auto opCtx = serviceContext.makeOperationContext();
QuerySettings querySettings;
- CollectionMock coll(TenantNamespace(boost::none, nss));
+ CollectionMock coll(nss);
addQueryShapeToPlanCache(opCtx.get(), &planCache, "{a: 2}", "{}", "{}", "{}");
ASSERT_TRUE(planCacheContains(opCtx.get(), planCache, "{a: 2}", "{}", "{}", "{}"));
diff --git a/src/mongo/db/commands/list_databases.cpp b/src/mongo/db/commands/list_databases.cpp
index 2e53357faaf..4b59a41f64e 100644
--- a/src/mongo/db/commands/list_databases.cpp
+++ b/src/mongo/db/commands/list_databases.cpp
@@ -44,7 +44,6 @@
#include "mongo/db/service_context.h"
#include "mongo/db/storage/storage_engine.h"
#include "mongo/db/tenant_database_name.h"
-#include "mongo/db/tenant_namespace.h"
namespace mongo {
diff --git a/src/mongo/db/commands/plan_cache_commands_test.cpp b/src/mongo/db/commands/plan_cache_commands_test.cpp
index c3f20772959..4ef229c36f4 100644
--- a/src/mongo/db/commands/plan_cache_commands_test.cpp
+++ b/src/mongo/db/commands/plan_cache_commands_test.cpp
@@ -41,7 +41,7 @@ namespace {
static const NamespaceString nss{"test.collection"_sd};
PlanCacheKey makeKey(const CanonicalQuery& cq) {
- CollectionMock coll(TenantNamespace(boost::none, nss));
+ CollectionMock coll(nss);
return plan_cache_key_factory::make<PlanCacheKey>(cq, &coll);
}
diff --git a/src/mongo/db/pipeline/document_source_change_stream_test.cpp b/src/mongo/db/pipeline/document_source_change_stream_test.cpp
index 302bbeeac18..3d6cd8110de 100644
--- a/src/mongo/db/pipeline/document_source_change_stream_test.cpp
+++ b/src/mongo/db/pipeline/document_source_change_stream_test.cpp
@@ -491,8 +491,7 @@ TEST_F(ChangeStreamStageTest, ShouldRejectBothStartAtOperationTimeAndResumeAfter
auto expCtx = getExpCtx();
// Need to put the collection in the collection catalog so the resume token is valid.
- std::shared_ptr<Collection> collection =
- std::make_shared<CollectionMock>(TenantNamespace(boost::none, nss));
+ std::shared_ptr<Collection> collection = std::make_shared<CollectionMock>(nss);
CollectionCatalog::write(expCtx->opCtx, [&](CollectionCatalog& catalog) {
catalog.registerCollection(expCtx->opCtx, testUuid(), std::move(collection));
});
@@ -514,8 +513,7 @@ TEST_F(ChangeStreamStageTest, ShouldRejectBothStartAfterAndResumeAfterOptions) {
auto opCtx = expCtx->opCtx;
// Need to put the collection in the collection catalog so the resume token is validcollection
- std::shared_ptr<Collection> collection =
- std::make_shared<CollectionMock>(TenantNamespace(boost::none, nss));
+ std::shared_ptr<Collection> collection = std::make_shared<CollectionMock>(nss);
CollectionCatalog::write(opCtx, [&](CollectionCatalog& catalog) {
catalog.registerCollection(opCtx, testUuid(), std::move(collection));
});
@@ -538,8 +536,7 @@ TEST_F(ChangeStreamStageTest, ShouldRejectBothStartAtOperationTimeAndStartAfterO
auto opCtx = expCtx->opCtx;
// Need to put the collection in the collection catalog so the resume token is valid.
- std::shared_ptr<Collection> collection =
- std::make_shared<CollectionMock>(TenantNamespace(boost::none, nss));
+ std::shared_ptr<Collection> collection = std::make_shared<CollectionMock>(nss);
CollectionCatalog::write(opCtx, [&](CollectionCatalog& catalog) {
catalog.registerCollection(opCtx, testUuid(), std::move(collection));
});
@@ -561,8 +558,7 @@ TEST_F(ChangeStreamStageTest, ShouldRejectResumeAfterWithResumeTokenMissingUUID)
auto opCtx = expCtx->opCtx;
// Need to put the collection in the collection catalog so the resume token is valid.
- std::shared_ptr<Collection> collection =
- std::make_shared<CollectionMock>(TenantNamespace(boost::none, nss));
+ std::shared_ptr<Collection> collection = std::make_shared<CollectionMock>(nss);
CollectionCatalog::write(opCtx, [&](CollectionCatalog& catalog) {
catalog.registerCollection(opCtx, testUuid(), std::move(collection));
});
@@ -2565,8 +2561,7 @@ TEST_F(ChangeStreamStageTest, DocumentKeyShouldIncludeShardKeyFromResumeTokenWhe
const auto opTime = repl::OpTime(ts, term);
const auto uuid = testUuid();
- std::shared_ptr<Collection> collection =
- std::make_shared<CollectionMock>(TenantNamespace(boost::none, nss));
+ std::shared_ptr<Collection> collection = std::make_shared<CollectionMock>(nss);
CollectionCatalog::write(getExpCtx()->opCtx, [&](CollectionCatalog& catalog) {
catalog.registerCollection(getExpCtx()->opCtx, uuid, std::move(collection));
});
@@ -2608,8 +2603,7 @@ TEST_F(ChangeStreamStageTest, DocumentKeyShouldPrioritizeO2FieldOverDocumentKeyC
const auto opTime = repl::OpTime(ts, term);
const auto uuid = testUuid();
- std::shared_ptr<Collection> collection =
- std::make_shared<CollectionMock>(TenantNamespace(boost::none, nss));
+ std::shared_ptr<Collection> collection = std::make_shared<CollectionMock>(nss);
CollectionCatalog::write(getExpCtx()->opCtx, [&](CollectionCatalog& catalog) {
catalog.registerCollection(getExpCtx()->opCtx, uuid, std::move(collection));
});
@@ -2652,8 +2646,7 @@ TEST_F(ChangeStreamStageTest, DocumentKeyShouldNotIncludeShardKeyFieldsIfNotPres
const auto opTime = repl::OpTime(ts, term);
const auto uuid = testUuid();
- std::shared_ptr<Collection> collection =
- std::make_shared<CollectionMock>(TenantNamespace(boost::none, nss));
+ std::shared_ptr<Collection> collection = std::make_shared<CollectionMock>(nss);
CollectionCatalog::write(getExpCtx()->opCtx, [&](CollectionCatalog& catalog) {
catalog.registerCollection(getExpCtx()->opCtx, uuid, std::move(collection));
});
@@ -2691,8 +2684,7 @@ TEST_F(ChangeStreamStageTest, ResumeAfterFailsIfResumeTokenDoesNotContainUUID) {
const Timestamp ts(3, 45);
const auto uuid = testUuid();
- std::shared_ptr<Collection> collection =
- std::make_shared<CollectionMock>(TenantNamespace(boost::none, nss));
+ std::shared_ptr<Collection> collection = std::make_shared<CollectionMock>(nss);
CollectionCatalog::write(getExpCtx()->opCtx, [&](CollectionCatalog& catalog) {
catalog.registerCollection(getExpCtx()->opCtx, uuid, std::move(collection));
});
@@ -2747,8 +2739,7 @@ TEST_F(ChangeStreamStageTest, ResumeAfterWithTokenFromInvalidateShouldFail) {
auto expCtx = getExpCtx();
// Need to put the collection in the collection catalog so the resume token is valid.
- std::shared_ptr<Collection> collection =
- std::make_shared<CollectionMock>(TenantNamespace(boost::none, nss));
+ std::shared_ptr<Collection> collection = std::make_shared<CollectionMock>(nss);
CollectionCatalog::write(expCtx->opCtx, [&](CollectionCatalog& catalog) {
catalog.registerCollection(getExpCtx()->opCtx, testUuid(), std::move(collection));
});
@@ -3479,8 +3470,7 @@ TEST_F(ChangeStreamStageDBTest,
const auto opTime = repl::OpTime(ts, term);
const auto uuid = testUuid();
- std::shared_ptr<Collection> collection =
- std::make_shared<CollectionMock>(TenantNamespace(boost::none, nss));
+ std::shared_ptr<Collection> collection = std::make_shared<CollectionMock>(nss);
CollectionCatalog::write(getExpCtx()->opCtx, [&](CollectionCatalog& catalog) {
catalog.registerCollection(getExpCtx()->opCtx, uuid, std::move(collection));
});
@@ -3517,8 +3507,7 @@ TEST_F(ChangeStreamStageDBTest, DocumentKeyShouldPrioritizeO2FieldOverDocumentKe
const auto opTime = repl::OpTime(ts, term);
const auto uuid = testUuid();
- std::shared_ptr<Collection> collection =
- std::make_shared<CollectionMock>(TenantNamespace(boost::none, nss));
+ std::shared_ptr<Collection> collection = std::make_shared<CollectionMock>(nss);
CollectionCatalog::write(getExpCtx()->opCtx, [&](CollectionCatalog& catalog) {
catalog.registerCollection(getExpCtx()->opCtx, uuid, std::move(collection));
});
@@ -3556,8 +3545,7 @@ TEST_F(ChangeStreamStageDBTest, DocumentKeyShouldNotIncludeShardKeyFieldsIfNotPr
const auto opTime = repl::OpTime(ts, term);
const auto uuid = testUuid();
- std::shared_ptr<Collection> collection =
- std::make_shared<CollectionMock>(TenantNamespace(boost::none, nss));
+ std::shared_ptr<Collection> collection = std::make_shared<CollectionMock>(nss);
CollectionCatalog::write(getExpCtx()->opCtx, [&](CollectionCatalog& catalog) {
catalog.registerCollection(getExpCtx()->opCtx, uuid, std::move(collection));
});
@@ -3593,8 +3581,7 @@ TEST_F(ChangeStreamStageDBTest, DocumentKeyShouldNotIncludeShardKeyIfResumeToken
const auto opTime = repl::OpTime(ts, term);
const auto uuid = testUuid();
- std::shared_ptr<Collection> collection =
- std::make_shared<CollectionMock>(TenantNamespace(boost::none, nss));
+ std::shared_ptr<Collection> collection = std::make_shared<CollectionMock>(nss);
CollectionCatalog::write(getExpCtx()->opCtx, [&](CollectionCatalog& catalog) {
catalog.registerCollection(getExpCtx()->opCtx, uuid, std::move(collection));
});
@@ -3629,8 +3616,7 @@ TEST_F(ChangeStreamStageDBTest, ResumeAfterWithTokenFromInvalidateShouldFail) {
auto expCtx = getExpCtx();
// Need to put the collection in the collection catalog so the resume token is valid.
- std::shared_ptr<Collection> collection =
- std::make_shared<CollectionMock>(TenantNamespace(boost::none, nss));
+ std::shared_ptr<Collection> collection = std::make_shared<CollectionMock>(nss);
CollectionCatalog::write(expCtx->opCtx, [&](CollectionCatalog& catalog) {
catalog.registerCollection(getExpCtx()->opCtx, testUuid(), std::move(collection));
});
@@ -3653,8 +3639,7 @@ TEST_F(ChangeStreamStageDBTest, ResumeAfterWithTokenFromInvalidateShouldFail) {
TEST_F(ChangeStreamStageDBTest, ResumeAfterWithTokenFromDropDatabase) {
const auto uuid = testUuid();
- std::shared_ptr<Collection> collection =
- std::make_shared<CollectionMock>(TenantNamespace(boost::none, nss));
+ std::shared_ptr<Collection> collection = std::make_shared<CollectionMock>(nss);
CollectionCatalog::write(getExpCtx()->opCtx, [&](CollectionCatalog& catalog) {
catalog.registerCollection(getExpCtx()->opCtx, uuid, std::move(collection));
});
@@ -3683,8 +3668,7 @@ TEST_F(ChangeStreamStageDBTest, ResumeAfterWithTokenFromDropDatabase) {
TEST_F(ChangeStreamStageDBTest, StartAfterSucceedsEvenIfResumeTokenDoesNotContainUUID) {
const auto uuid = testUuid();
- std::shared_ptr<Collection> collection =
- std::make_shared<CollectionMock>(TenantNamespace(boost::none, nss));
+ std::shared_ptr<Collection> collection = std::make_shared<CollectionMock>(nss);
CollectionCatalog::write(getExpCtx()->opCtx, [&](CollectionCatalog& catalog) {
catalog.registerCollection(getExpCtx()->opCtx, uuid, std::move(collection));
});
diff --git a/src/mongo/db/pipeline/document_source_check_resume_token_test.cpp b/src/mongo/db/pipeline/document_source_check_resume_token_test.cpp
index afa2f70a422..05c7accf3a9 100644
--- a/src/mongo/db/pipeline/document_source_check_resume_token_test.cpp
+++ b/src/mongo/db/pipeline/document_source_check_resume_token_test.cpp
@@ -95,8 +95,7 @@ private:
class ChangeStreamOplogCollectionMock : public CollectionMock {
public:
- ChangeStreamOplogCollectionMock()
- : CollectionMock(TenantNamespace(boost::none, NamespaceString::kRsOplogNamespace)) {
+ ChangeStreamOplogCollectionMock() : CollectionMock(NamespaceString::kRsOplogNamespace) {
_recordStore =
_devNullEngine.getRecordStore(nullptr, NamespaceString::kRsOplogNamespace.ns(), "", {});
}
diff --git a/src/mongo/db/query/canonical_query_encoder_test.cpp b/src/mongo/db/query/canonical_query_encoder_test.cpp
index 0cf620e85fb..b23347329b6 100644
--- a/src/mongo/db/query/canonical_query_encoder_test.cpp
+++ b/src/mongo/db/query/canonical_query_encoder_test.cpp
@@ -49,7 +49,7 @@ using std::unique_ptr;
static const NamespaceString nss("testdb.testcoll");
PlanCacheKey makeKey(const CanonicalQuery& cq) {
- CollectionMock coll(TenantNamespace(boost::none, nss));
+ CollectionMock coll(nss);
return plan_cache_key_factory::make<PlanCacheKey>(cq, &coll);
}
diff --git a/src/mongo/db/query/sbe_stage_builder_test_fixture.cpp b/src/mongo/db/query/sbe_stage_builder_test_fixture.cpp
index ff0207a7f5c..24a2669dda0 100644
--- a/src/mongo/db/query/sbe_stage_builder_test_fixture.cpp
+++ b/src/mongo/db/query/sbe_stage_builder_test_fixture.cpp
@@ -61,7 +61,7 @@ SbeStageBuilderTestFixture::buildPlanStage(
CanonicalQuery::canonicalize(opCtx(), std::move(findCommand), false, expCtx);
ASSERT_OK(statusWithCQ.getStatus());
- CollectionMock coll(TenantNamespace(boost::none, _nss));
+ CollectionMock coll(_nss);
CollectionPtr collPtr(&coll);
MultipleCollectionAccessor& colls = _collections;
if (shardFiltererInterface) {
diff --git a/src/mongo/db/repair.cpp b/src/mongo/db/repair.cpp
index c889bb7cbc0..4857cadd9a1 100644
--- a/src/mongo/db/repair.cpp
+++ b/src/mongo/db/repair.cpp
@@ -59,7 +59,6 @@
#include "mongo/db/storage/storage_engine.h"
#include "mongo/db/storage/storage_repair_observer.h"
#include "mongo/db/storage/storage_util.h"
-#include "mongo/db/tenant_namespace.h"
#include "mongo/db/vector_clock.h"
#include "mongo/logv2/log.h"
#include "mongo/util/scopeguard.h"
diff --git a/src/mongo/db/repl/apply_ops.cpp b/src/mongo/db/repl/apply_ops.cpp
index fdd97dd42bd..5f71c23b3ab 100644
--- a/src/mongo/db/repl/apply_ops.cpp
+++ b/src/mongo/db/repl/apply_ops.cpp
@@ -107,7 +107,7 @@ Status _applyOps(OperationContext* opCtx,
// ApplyOps does not have the global writer lock when applying transaction
// operations, so we need to acquire the DB and Collection locks.
Lock::DBLock dbLock(opCtx, nss.db(), MODE_IX);
- // TODO SERVER-62880 Parse the tenant id from the TenantNamespace.
+ // TODO SERVER-64608 Use the tenantID from 'nss' to construct the DatabaseName
const TenantDatabaseName tenantDbName(boost::none, nss.db());
auto databaseHolder = DatabaseHolder::get(opCtx);
auto db = databaseHolder->getDb(opCtx, tenantDbName);
diff --git a/src/mongo/db/repl/rollback_impl.cpp b/src/mongo/db/repl/rollback_impl.cpp
index a0e10f2bf51..1cec7be6b30 100644
--- a/src/mongo/db/repl/rollback_impl.cpp
+++ b/src/mongo/db/repl/rollback_impl.cpp
@@ -66,7 +66,6 @@
#include "mongo/db/storage/historical_ident_tracker.h"
#include "mongo/db/storage/remove_saver.h"
#include "mongo/db/tenant_database_name.h"
-#include "mongo/db/tenant_namespace.h"
#include "mongo/db/transaction_history_iterator.h"
#include "mongo/logv2/log.h"
#include "mongo/s/catalog/type_config_version.h"
diff --git a/src/mongo/db/repl/rollback_impl_test.cpp b/src/mongo/db/repl/rollback_impl_test.cpp
index fe3f17c40d0..afab6b658a7 100644
--- a/src/mongo/db/repl/rollback_impl_test.cpp
+++ b/src/mongo/db/repl/rollback_impl_test.cpp
@@ -48,7 +48,6 @@
#include "mongo/db/s/operation_sharding_state.h"
#include "mongo/db/s/type_shard_identity.h"
#include "mongo/db/service_context.h"
-#include "mongo/db/tenant_namespace.h"
#include "mongo/logv2/log.h"
#include "mongo/s/catalog/type_config_version.h"
#include "mongo/stdx/thread.h"
@@ -170,7 +169,7 @@ protected:
ASSERT_OK(_storageInterface->createCollection(opCtx, nss, options));
// Initialize a mock collection.
- return std::make_unique<CollectionMock>(TenantNamespace(boost::none, nss));
+ return std::make_unique<CollectionMock>(nss);
}
/**
diff --git a/src/mongo/db/repl/storage_interface_impl.cpp b/src/mongo/db/repl/storage_interface_impl.cpp
index ce7d262733d..db56bcceff1 100644
--- a/src/mongo/db/repl/storage_interface_impl.cpp
+++ b/src/mongo/db/repl/storage_interface_impl.cpp
@@ -82,7 +82,6 @@
#include "mongo/db/storage/control/storage_control.h"
#include "mongo/db/storage/oplog_cap_maintainer_thread.h"
#include "mongo/db/tenant_database_name.h"
-#include "mongo/db/tenant_namespace.h"
#include "mongo/logv2/log.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/background.h"
diff --git a/src/mongo/db/repl/storage_timestamp_test.cpp b/src/mongo/db/repl/storage_timestamp_test.cpp
index b128b2bad20..f1a5eae10ff 100644
--- a/src/mongo/db/repl/storage_timestamp_test.cpp
+++ b/src/mongo/db/repl/storage_timestamp_test.cpp
@@ -86,7 +86,6 @@
#include "mongo/db/session_catalog_mongod.h"
#include "mongo/db/storage/snapshot_manager.h"
#include "mongo/db/storage/storage_engine_impl.h"
-#include "mongo/db/tenant_namespace.h"
#include "mongo/db/transaction_participant.h"
#include "mongo/db/transaction_participant_gen.h"
#include "mongo/db/vector_clock_mutable.h"
@@ -3026,8 +3025,8 @@ TEST_F(StorageTimestampTest, ViewCreationSeparateTransaction) {
<< " incorrectly exists before creation. CreateTs: " << systemViewsCreateTs;
systemViewsMd = getMetaDataAtTime(durableCatalog, catalogId, systemViewsCreateTs);
- TenantNamespace tenantNs = systemViewsMd->tenantNs;
- ASSERT_EQ(systemViewsNss.ns(), tenantNs.getNss().ns());
+ auto nss = systemViewsMd->ns;
+ ASSERT_EQ(systemViewsNss.ns(), nss);
assertDocumentAtTimestamp(autoColl.getCollection(), systemViewsCreateTs, BSONObj());
assertDocumentAtTimestamp(autoColl.getCollection(),
diff --git a/src/mongo/db/repl/tenant_migration_shard_merge_util.cpp b/src/mongo/db/repl/tenant_migration_shard_merge_util.cpp
index 8e508f2519f..ae0e4b0bb5e 100644
--- a/src/mongo/db/repl/tenant_migration_shard_merge_util.cpp
+++ b/src/mongo/db/repl/tenant_migration_shard_merge_util.cpp
@@ -190,16 +190,14 @@ void wiredTigerImportFromBackupCursor(OperationContext* opCtx,
});
// Create Collection object
- TenantNamespace tenantNs(getActiveTenant(opCtx), nss);
auto storageEngine = opCtx->getServiceContext()->getStorageEngine();
auto durableCatalog = storageEngine->getCatalog();
ImportOptions importOptions(ImportOptions::ImportCollectionUUIDOption::kKeepOld);
importOptions.importTimestampRule = ImportOptions::ImportTimestampRule::kStable;
- // TODO SERVER-62659 Ensure the correct tenantId is used when importing the collection.
auto importResult = uassertStatusOK(
DurableCatalog::get(opCtx)->importCollection(opCtx,
- tenantNs,
+ collectionMetadata.ns,
collectionMetadata.catalogObject,
storageMetadata.done(),
importOptions));
@@ -209,7 +207,7 @@ void wiredTigerImportFromBackupCursor(OperationContext* opCtx,
}
std::shared_ptr<Collection> ownedCollection = Collection::Factory::get(opCtx)->make(
- opCtx, tenantNs, importResult.catalogId, md, std::move(importResult.rs));
+ opCtx, nss, importResult.catalogId, md, std::move(importResult.rs));
ownedCollection->init(opCtx);
ownedCollection->setCommitted(false);
diff --git a/src/mongo/db/s/config/sharding_catalog_manager_shard_collection_test.cpp b/src/mongo/db/s/config/sharding_catalog_manager_shard_collection_test.cpp
index 8cb835f0e6a..6b15afaf5b0 100644
--- a/src/mongo/db/s/config/sharding_catalog_manager_shard_collection_test.cpp
+++ b/src/mongo/db/s/config/sharding_catalog_manager_shard_collection_test.cpp
@@ -37,7 +37,6 @@
#include "mongo/db/catalog/collection_mock.h"
#include "mongo/db/s/config/config_server_test_fixture.h"
#include "mongo/db/s/config/initial_split_policy.h"
-#include "mongo/db/tenant_namespace.h"
#include "mongo/rpc/metadata/tracking_metadata.h"
#include "mongo/s/balancer_configuration.h"
#include "mongo/s/catalog/type_chunk.h"
@@ -150,9 +149,7 @@ TEST_F(CreateFirstChunksTest, NonEmptyCollection_SplitPoints_FromSplitVector_Man
auto uuid = UUID::gen();
CollectionCatalog::write(getServiceContext(), [&](CollectionCatalog& catalog) {
catalog.registerCollection(
- operationContext(),
- uuid,
- std::make_shared<CollectionMock>(TenantNamespace(boost::none, kNamespace)));
+ operationContext(), uuid, std::make_shared<CollectionMock>(kNamespace));
});
auto future = launchAsync([&] {
diff --git a/src/mongo/db/server_feature_flags.idl b/src/mongo/db/server_feature_flags.idl
index 47ffebbe3f2..3231873385a 100644
--- a/src/mongo/db/server_feature_flags.idl
+++ b/src/mongo/db/server_feature_flags.idl
@@ -38,7 +38,7 @@ feature_flags:
# Only available with the server parameter "multitenancySupport".
description: >-
When enabled in conjunction with the server parameter "multitenancySupport",
- require tenantID to be a part of TenantNamespace and TenantDatabase.
+ require tenantID to be a part of NamespaceString and TenantDatabase.
cpp_varname: gFeatureFlagRequireTenantID
default: false
featureFlagUserWriteBlocking:
diff --git a/src/mongo/db/startup_recovery.cpp b/src/mongo/db/startup_recovery.cpp
index aed1131d95d..eb2f4e0ed29 100644
--- a/src/mongo/db/startup_recovery.cpp
+++ b/src/mongo/db/startup_recovery.cpp
@@ -54,7 +54,6 @@
#include "mongo/db/repl_set_member_in_standalone_mode.h"
#include "mongo/db/server_options.h"
#include "mongo/db/storage/storage_repair_observer.h"
-#include "mongo/db/tenant_namespace.h"
#include "mongo/logv2/log.h"
#include "mongo/util/exit.h"
#include "mongo/util/fail_point.h"
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);
diff --git a/src/mongo/db/tenant_namespace.cpp b/src/mongo/db/tenant_namespace.cpp
deleted file mode 100644
index d1742e639d8..00000000000
--- a/src/mongo/db/tenant_namespace.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- * Copyright (C) 2022-present MongoDB, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the Server Side Public License, version 1,
- * as published by MongoDB, Inc.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * Server Side Public License for more details.
- *
- * You should have received a copy of the Server Side Public License
- * along with this program. If not, see
- * <http://www.mongodb.com/licensing/server-side-public-license>.
- *
- * As a special exception, the copyright holders give permission to link the
- * code of portions of this program with the OpenSSL library under certain
- * conditions as described in each individual source file and distribute
- * linked combinations including the program with the OpenSSL library. You
- * must comply with the Server Side Public License in all respects for
- * all of the code used other than as permitted herein. If you modify file(s)
- * with this exception, you may extend this exception to your version of the
- * file(s), but you are not obligated to do so. If you do not wish to do so,
- * delete this exception statement from your version. If you delete this
- * exception statement from all source files in the program, then also delete
- * it in the license file.
- */
-
-#include "mongo/db/tenant_namespace.h"
-
-#include "mongo/db/multitenancy_gen.h"
-#include "mongo/db/server_feature_flags_gen.h"
-
-namespace mongo {
-
-TenantNamespace::TenantNamespace(boost::optional<mongo::TenantId> tenantId, NamespaceString nss) {
- // TODO SERVER-62114 Check instead if gMultitenancySupport is enabled.
- if (gFeatureFlagRequireTenantID.isEnabledAndIgnoreFCV())
- invariant(tenantId);
-
- _tenantId = tenantId;
- _nss = nss;
- _tenantNsStr = _tenantId ? boost::make_optional(_tenantId->toString() + "_" + _nss.toString())
- : boost::none;
-}
-
-TenantDatabaseName TenantNamespace::createTenantDatabaseName() const {
- return TenantDatabaseName(_tenantId, _nss.db());
-}
-
-TenantNamespace TenantNamespace::parseTenantNamespaceFromDisk(StringData ns) {
- if (!gMultitenancySupport) {
- return TenantNamespace(boost::none, NamespaceString(ns));
- }
-
- auto tenantDelim = ns.find('_');
- auto collDelim = ns.find('.');
- // If the first '_' is after the '.' that separates the db and coll names, the '_' is part
- // of the coll name and is not a db prefix.
- if (tenantDelim == std::string::npos || collDelim < tenantDelim) {
- return TenantNamespace(boost::none, NamespaceString(ns));
- }
-
- const TenantId tenantId(OID(ns.substr(0, tenantDelim)));
- auto nss = NamespaceString(ns.substr(tenantDelim + 1, ns.size() - 1 - tenantDelim));
- return TenantNamespace(tenantId, nss);
-}
-
-std::ostream& operator<<(std::ostream& stream, const TenantNamespace& tenantNs) {
- return stream << tenantNs.toString();
-}
-
-StringBuilder& operator<<(StringBuilder& builder, const TenantNamespace& tenantNs) {
- return builder << tenantNs.toString();
-}
-
-} // namespace mongo
diff --git a/src/mongo/db/tenant_namespace.h b/src/mongo/db/tenant_namespace.h
deleted file mode 100644
index bb07dabf2bd..00000000000
--- a/src/mongo/db/tenant_namespace.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/**
- * Copyright (C) 2021-present MongoDB, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the Server Side Public License, version 1,
- * as published by MongoDB, Inc.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * Server Side Public License for more details.
- *
- * You should have received a copy of the Server Side Public License
- * along with this program. If not, see
- * <http://www.mongodb.com/licensing/server-side-public-license>.
- *
- * As a special exception, the copyright holders give permission to link the
- * code of portions of this program with the OpenSSL library under certain
- * conditions as described in each individual source file and distribute
- * linked combinations including the program with the OpenSSL library. You
- * must comply with the Server Side Public License in all respects for
- * all of the code used other than as permitted herein. If you modify file(s)
- * with this exception, you may extend this exception to your version of the
- * file(s), but you are not obligated to do so. If you do not wish to do so,
- * delete this exception statement from your version. If you delete this
- * exception statement from all source files in the program, then also delete
- * it in the license file.
- */
-
-#pragma once
-
-#include <algorithm>
-#include <boost/optional.hpp>
-#include <iosfwd>
-#include <string>
-
-#include "mongo/base/string_data.h"
-#include "mongo/bson/util/builder.h"
-#include "mongo/db/namespace_string.h"
-#include "mongo/db/tenant_database_name.h"
-#include "mongo/db/tenant_id.h"
-#include "mongo/logv2/log_attr.h"
-
-namespace mongo {
-
-class TenantNamespace {
-public:
- TenantNamespace(const TenantNamespace& tenantNs) = default;
-
- /**
- * Constructs an empty TenantNamespace.
- */
- TenantNamespace() = default;
-
- /**
- * Constructs a TenantNamespace from the given tenantId and NamespaceString.
- *
- * If featureFlagRequireTenantID is set, tenantId is required.
- */
- TenantNamespace(boost::optional<mongo::TenantId> tenantId, NamespaceString nss);
-
- /**
- * Create a TenantDatabaseName from the TenantNamespace.
- */
- TenantDatabaseName createTenantDatabaseName() const;
-
- /**
- * Constructs a TenantNamespace from the string "ns". When the server parameter
- * "multitenancySupport” is enabled, the tenantId will be parsed separately from the database
- * name. If it is disabled, the tenantId will be parsed as a prefix of the database name, and
- * the tenantId field will be empty. For example:
- * if “multitenancySupport” is enabled, "tenant1_dbA.collA" will be parsed as:
- * _tenantId = tenant1
- * _nss = NamespaceString(dbA.collA)
- *
- * if “multitenancySupport” is disabled, "tenant1_dbA.collA" will be parsed as:
- * _tenantId = boost::none
- * _nss = NamespaceString(tenant1_dbA.collA), and the _nss,db()
- *
- * This method should only be used when reading a namespace from disk. To construct a
- * TenantNamespace otherwise, use the standard constructor above.
- *
- * If featureFlagRequireTenantID is set, tenantId is required.
- */
- static TenantNamespace parseTenantNamespaceFromDisk(StringData ns);
-
- boost::optional<TenantId> tenantId() const {
- return _tenantId;
- }
-
- StringData db() const {
- return _nss.db();
- }
-
- StringData coll() const {
- return _nss.coll();
- }
-
- const NamespaceString& getNss() const {
- return _nss;
- }
-
- std::string toString() const {
- if (_tenantNsStr)
- return *_tenantNsStr;
-
- invariant(!_tenantId);
- return _nss.ns();
- }
-
- // Relops among `TenantNamespace`.
- friend bool operator==(const TenantNamespace& a, const TenantNamespace& b) {
- return a.toString() == b.toString();
- }
- friend bool operator!=(const TenantNamespace& a, const TenantNamespace& b) {
- return a.toString() != b.toString();
- }
- friend bool operator<(const TenantNamespace& a, const TenantNamespace& b) {
- return a.toString() < b.toString();
- }
- friend bool operator>(const TenantNamespace& a, const TenantNamespace& b) {
- return a.toString() > b.toString();
- }
- friend bool operator<=(const TenantNamespace& a, const TenantNamespace& b) {
- return a.toString() <= b.toString();
- }
- friend bool operator>=(const TenantNamespace& a, const TenantNamespace& b) {
- return a.toString() >= b.toString();
- }
-
- template <typename H>
- friend H AbslHashValue(H h, const TenantNamespace& tenantNs) {
- return H::combine(std::move(h), tenantNs.toString());
- }
-
- friend auto logAttrs(const TenantNamespace& nss) {
- return "namespace"_attr = nss;
- }
-
-private:
- boost::optional<TenantId> _tenantId;
- NamespaceString _nss{};
- boost::optional<std::string> _tenantNsStr; // Only set if _tenantId exists
-};
-
-std::ostream& operator<<(std::ostream& stream, const TenantNamespace& tenantNs);
-StringBuilder& operator<<(StringBuilder& builder, const TenantNamespace& tenantNs);
-
-} // namespace mongo
diff --git a/src/mongo/db/tenant_namespace_test.cpp b/src/mongo/db/tenant_namespace_test.cpp
deleted file mode 100644
index 685665fc78e..00000000000
--- a/src/mongo/db/tenant_namespace_test.cpp
+++ /dev/null
@@ -1,148 +0,0 @@
-/**
- * Copyright (C) 2021-present MongoDB, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the Server Side Public License, version 1,
- * as published by MongoDB, Inc.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * Server Side Public License for more details.
- *
- * You should have received a copy of the Server Side Public License
- * along with this program. If not, see
- * <http://www.mongodb.com/licensing/server-side-public-license>.
- *
- * As a special exception, the copyright holders give permission to link the
- * code of portions of this program with the OpenSSL library under certain
- * conditions as described in each individual source file and distribute
- * linked combinations including the program with the OpenSSL library. You
- * must comply with the Server Side Public License in all respects for
- * all of the code used other than as permitted herein. If you modify file(s)
- * with this exception, you may extend this exception to your version of the
- * file(s), but you are not obligated to do so. If you do not wish to do so,
- * delete this exception statement from your version. If you delete this
- * exception statement from all source files in the program, then also delete
- * it in the license file.
- */
-
-#include "mongo/db/multitenancy_gen.h"
-#include "mongo/db/server_feature_flags_gen.h"
-#include "mongo/db/tenant_namespace.h"
-#include "mongo/idl/server_parameter_test_util.h"
-#include "mongo/unittest/death_test.h"
-#include "mongo/unittest/unittest.h"
-
-namespace mongo {
-namespace {
-
-TEST(TenantNamespaceTest, TenantNamespaceMultitenancySupportDisabledBasic) {
- RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", false);
- TenantNamespace tenantNs(boost::none, NamespaceString("a.b"));
- ASSERT(!tenantNs.tenantId());
- ASSERT_EQUALS(std::string("a"), tenantNs.db());
- ASSERT_EQUALS(std::string("b"), tenantNs.coll());
- ASSERT_EQUALS(std::string("a.b"), tenantNs.toString());
-}
-
-TEST(TenantNamespaceTest, TenantNamespaceParseFromDiskMultitenancySupportDisabled) {
- RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", false);
- TenantNamespace tenantNs = TenantNamespace::parseTenantNamespaceFromDisk("a.b");
- ASSERT(!tenantNs.tenantId());
- ASSERT_EQUALS(std::string("a"), tenantNs.db());
- ASSERT_EQUALS(std::string("b"), tenantNs.coll());
-
- TenantId tenantId(OID::gen());
- std::string ns = tenantId.toString() + "_a.b";
- TenantNamespace tenantNs2 = TenantNamespace::parseTenantNamespaceFromDisk(ns);
- ASSERT(!tenantNs2.tenantId());
- ASSERT_EQUALS(std::string(tenantId.toString() + "_a"), tenantNs2.db());
- ASSERT_EQUALS(std::string("b"), tenantNs2.coll());
-}
-
-TEST(TenantNamespaceTest, TenantNamespaceMultitenancySupportEnabledFeatureFlagDisabledBasic) {
- // TODO SERVER-62114 Remove this test case.
- RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", true);
-
- // If the feature flag is disabled, it's acceptable for the tenantId not to exist.
- TenantNamespace tenantNs(boost::none, NamespaceString("a.b"));
- ASSERT(!tenantNs.tenantId());
- ASSERT_EQUALS(std::string("a"), tenantNs.db());
- ASSERT_EQUALS(std::string("b"), tenantNs.coll());
- ASSERT_EQUALS(std::string("a.b"), tenantNs.toString());
-
- // If the feature flag is disabled but a tenantId is given, the tenantId should be parsed
- // separately from the db name.
- TenantId tenantId(OID::gen());
- TenantNamespace tenantNs2(tenantId, NamespaceString("a.b"));
- ASSERT(tenantNs2.tenantId());
- ASSERT_EQUALS(tenantId, *tenantNs2.tenantId());
- ASSERT_EQUALS(std::string("a"), tenantNs2.db());
- ASSERT_EQUALS(std::string("b"), tenantNs2.coll());
- ASSERT_EQUALS(std::string(tenantId.toString() + "_a.b"), tenantNs2.toString());
-}
-
-DEATH_TEST(TenantNamespaceTest,
- TenantNamespaceMultitenancySupportEnabledTenantIDRequired,
- "invariant") {
- RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", true);
- // TODO SERVER-62114 Remove enabling this feature flag.
- RAIIServerParameterControllerForTest featureFlagController("featureFlagRequireTenantID", true);
-
- // A tenantId is not included, so the server should crash
- TenantNamespace(boost::none, NamespaceString("a.b"));
-}
-
-DEATH_TEST(TenantNamespaceTest,
- TenantNamespaceParseFromDiskMultitenancySupportEnabledTenantIDRequired,
- "invariant") {
- RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", true);
- // TODO SERVER-62114 Remove enabling this feature flag.
- RAIIServerParameterControllerForTest featureFlagController("featureFlagRequireTenantID", true);
-
- // A tenantId is not included, so the server should crash
- auto tenantNs = TenantNamespace::parseTenantNamespaceFromDisk("a.b");
-}
-
-TEST(TenantNamespaceTest, TenantNamespaceMultitenancySupportEnabledBasic) {
- RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", true);
- // TODO SERVER-62114 Remove enabling this feature flag.
- RAIIServerParameterControllerForTest featureFlagController("featureFlagRequireTenantID", true);
-
- TenantId tenantId(OID::gen());
- TenantNamespace tenantNs(tenantId, NamespaceString("a.b"));
- ASSERT(tenantNs.tenantId());
- ASSERT_EQUALS(tenantId, *tenantNs.tenantId());
- ASSERT_EQUALS(std::string("a"), tenantNs.db());
- ASSERT_EQUALS(std::string("b"), tenantNs.coll());
- ASSERT_EQUALS(std::string(tenantId.toString() + "_a.b"), tenantNs.toString());
-}
-
-TEST(TenantNamespaceTest, TenantNamespaceParseFromDiskMultitenancySupportEnabled) {
- RAIIServerParameterControllerForTest multitenanyController("multitenancySupport", true);
- // TODO SERVER-62114 Remove enabling this feature flag.
- RAIIServerParameterControllerForTest featureFlagController("featureFlagRequireTenantID", true);
-
- TenantId tenantId(OID::gen());
- std::string tenantNsStr = str::stream() << tenantId << "_a.b";
-
- TenantNamespace tenantNs = TenantNamespace::parseTenantNamespaceFromDisk(tenantNsStr);
- ASSERT(tenantNs.tenantId());
- ASSERT_EQUALS(tenantId, *tenantNs.tenantId());
- ASSERT_EQUALS(std::string("a"), tenantNs.db());
- ASSERT_EQUALS(std::string("b"), tenantNs.coll());
-}
-
-TEST(TenantNamespaceTest, TestCopyConstructor) {
- TenantId tenantId(OID::gen());
- TenantNamespace tenantNs(tenantId, NamespaceString("a.b"));
- TenantNamespace clonedTenantNs(tenantNs);
- ASSERT_EQUALS(tenantNs, clonedTenantNs);
- ASSERT_EQUALS(*tenantNs.tenantId(), *clonedTenantNs.tenantId());
- ASSERT_EQUALS(tenantNs.db(), clonedTenantNs.db());
- ASSERT_EQUALS(tenantNs.coll(), clonedTenantNs.coll());
-}
-
-} // namespace
-} // namespace mongo