summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSophia Tan <sophia_tll@hotmail.com>2022-05-18 19:41:20 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-05-19 18:19:03 +0000
commitb065a3b04ab6c14b7a695f0c3f97eaa81b202a36 (patch)
treeaacf818dfbefcc6953a9db5da6db6b0ac54983a5
parenteb90659062d8ac2dfd629b5d672c67423bddaa6a (diff)
downloadmongo-b065a3b04ab6c14b7a695f0c3f97eaa81b202a36.tar.gz
SERVER-63109 Change CollectionCatalog::_databaseProfileSettings to be keyed by DatabaseName
-rw-r--r--src/mongo/db/catalog/collection_catalog.cpp6
-rw-r--r--src/mongo/db/catalog/collection_catalog.h10
-rw-r--r--src/mongo/db/catalog/collection_catalog_test.cpp4
-rw-r--r--src/mongo/db/catalog/create_collection.cpp8
-rw-r--r--src/mongo/db/catalog/database_holder_impl.cpp5
-rw-r--r--src/mongo/db/catalog/database_impl.cpp2
-rw-r--r--src/mongo/db/catalog/drop_collection.cpp6
-rw-r--r--src/mongo/db/catalog/rename_collection.cpp6
-rw-r--r--src/mongo/db/commands/create_indexes.cpp2
-rw-r--r--src/mongo/db/commands/dbcommands.cpp5
-rw-r--r--src/mongo/db/commands/dbcommands_d.cpp10
-rw-r--r--src/mongo/db/commands/find_and_modify.cpp4
-rw-r--r--src/mongo/db/commands/getmore_cmd.cpp4
-rw-r--r--src/mongo/db/commands/killcursors_cmd.cpp11
-rw-r--r--src/mongo/db/commands/profile_common.cpp14
-rw-r--r--src/mongo/db/commands/profile_common.h2
-rw-r--r--src/mongo/db/db_raii.cpp20
-rw-r--r--src/mongo/db/ops/write_ops_exec.cpp12
-rw-r--r--src/mongo/db/repl/tenant_migration_shard_merge_util.cpp2
-rw-r--r--src/mongo/db/s/shardsvr_collmod_command.cpp2
-rw-r--r--src/mongo/db/s/shardsvr_drop_collection_command.cpp2
-rw-r--r--src/mongo/db/s/shardsvr_drop_database_command.cpp2
-rw-r--r--src/mongo/db/s/shardsvr_drop_indexes_command.cpp2
-rw-r--r--src/mongo/db/transaction_history_iterator.cpp13
-rw-r--r--src/mongo/s/commands/cluster_profile_cmd.cpp2
25 files changed, 82 insertions, 74 deletions
diff --git a/src/mongo/db/catalog/collection_catalog.cpp b/src/mongo/db/catalog/collection_catalog.cpp
index 4b7d655d69d..cd6cb68f8a5 100644
--- a/src/mongo/db/catalog/collection_catalog.cpp
+++ b/src/mongo/db/catalog/collection_catalog.cpp
@@ -1091,12 +1091,12 @@ std::vector<DatabaseName> CollectionCatalog::getAllDbNames() const {
}
void CollectionCatalog::setDatabaseProfileSettings(
- StringData dbName, CollectionCatalog::ProfileSettings newProfileSettings) {
+ const DatabaseName& dbName, CollectionCatalog::ProfileSettings newProfileSettings) {
_databaseProfileSettings[dbName] = newProfileSettings;
}
CollectionCatalog::ProfileSettings CollectionCatalog::getDatabaseProfileSettings(
- StringData dbName) const {
+ const DatabaseName& dbName) const {
auto it = _databaseProfileSettings.find(dbName);
if (it != _databaseProfileSettings.end()) {
return it->second;
@@ -1105,7 +1105,7 @@ CollectionCatalog::ProfileSettings CollectionCatalog::getDatabaseProfileSettings
return {serverGlobalParams.defaultProfile, ProfileFilter::getDefault()};
}
-void CollectionCatalog::clearDatabaseProfileSettings(StringData dbName) {
+void CollectionCatalog::clearDatabaseProfileSettings(const DatabaseName& dbName) {
_databaseProfileSettings.erase(dbName);
}
diff --git a/src/mongo/db/catalog/collection_catalog.h b/src/mongo/db/catalog/collection_catalog.h
index 2ed0ca69e6b..3bdbd87540d 100644
--- a/src/mongo/db/catalog/collection_catalog.h
+++ b/src/mongo/db/catalog/collection_catalog.h
@@ -411,14 +411,14 @@ public:
/**
* Sets 'newProfileSettings' as the profiling settings for the database 'dbName'.
*/
- void setDatabaseProfileSettings(StringData dbName, ProfileSettings newProfileSettings);
+ void setDatabaseProfileSettings(const DatabaseName& dbName, ProfileSettings newProfileSettings);
/**
* Fetches the profiling settings for database 'dbName'.
*
* Returns the server's default database profile settings if the database does not exist.
*/
- ProfileSettings getDatabaseProfileSettings(StringData dbName) const;
+ ProfileSettings getDatabaseProfileSettings(const DatabaseName& dbName) const;
/**
* Fetches the profiling level for database 'dbName'.
@@ -428,14 +428,14 @@ public:
* There is no corresponding setDatabaseProfileLevel; use setDatabaseProfileSettings instead.
* This method only exists as a convenience.
*/
- int getDatabaseProfileLevel(StringData dbName) const {
+ int getDatabaseProfileLevel(const DatabaseName& dbName) const {
return getDatabaseProfileSettings(dbName).level;
}
/**
* Clears the database profile settings entry for 'dbName'.
*/
- void clearDatabaseProfileSettings(StringData dbName);
+ void clearDatabaseProfileSettings(const DatabaseName& dbName);
/**
* Statistics for the types of collections in the catalog.
@@ -605,7 +605,7 @@ private:
using NamespaceCollectionMap =
stdx::unordered_map<NamespaceString, std::shared_ptr<Collection>>;
using UncommittedViewsSet = stdx::unordered_set<NamespaceString>;
- using DatabaseProfileSettingsMap = StringMap<ProfileSettings>;
+ using DatabaseProfileSettingsMap = stdx::unordered_map<DatabaseName, ProfileSettings>;
using ViewsForDatabaseMap = stdx::unordered_map<DatabaseName, ViewsForDatabase>;
CollectionCatalogMap _catalog;
diff --git a/src/mongo/db/catalog/collection_catalog_test.cpp b/src/mongo/db/catalog/collection_catalog_test.cpp
index 521c3938663..e876ab41de9 100644
--- a/src/mongo/db/catalog/collection_catalog_test.cpp
+++ b/src/mongo/db/catalog/collection_catalog_test.cpp
@@ -642,8 +642,8 @@ TEST_F(CollectionCatalogTest, GetAllCollectionNamesAndGetAllDbNames) {
// Test setting and fetching the profile level for a database.
TEST_F(CollectionCatalogTest, DatabaseProfileLevel) {
- std::string testDBNameFirst = "testdbfirst";
- std::string testDBNameSecond = "testdbsecond";
+ DatabaseName testDBNameFirst(boost::none, "testdbfirst");
+ DatabaseName testDBNameSecond(boost::none, "testdbsecond");
// Requesting a profile level that is not in the _databaseProfileLevel map should return the
// default server-wide setting
diff --git a/src/mongo/db/catalog/create_collection.cpp b/src/mongo/db/catalog/create_collection.cpp
index 81ef7a641e3..ffa70dc447a 100644
--- a/src/mongo/db/catalog/create_collection.cpp
+++ b/src/mongo/db/catalog/create_collection.cpp
@@ -196,7 +196,7 @@ Status _createView(OperationContext* opCtx,
nss,
Top::LockType::NotLocked,
AutoStatsTracker::LogMode::kUpdateTopAndCurOp,
- CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(nss.db()));
+ CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(nss.dbName()));
// If the view creation rolls back, ensure that the Top entry created for the view is
// deleted.
@@ -312,7 +312,7 @@ Status _createTimeseries(OperationContext* opCtx,
bucketsNs,
Top::LockType::NotLocked,
AutoStatsTracker::LogMode::kUpdateTopAndCurOp,
- CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(ns.db()));
+ CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(ns.dbName()));
// If the buckets collection and time-series view creation roll back, ensure that their
// Top entries are deleted.
@@ -394,7 +394,7 @@ Status _createTimeseries(OperationContext* opCtx,
ns,
Top::LockType::NotLocked,
AutoStatsTracker::LogMode::kUpdateTopAndCurOp,
- catalog->getDatabaseProfileLevel(ns.db()));
+ catalog->getDatabaseProfileLevel(ns.dbName()));
// If the buckets collection and time-series view creation roll back, ensure that their
// Top entries are deleted.
@@ -515,7 +515,7 @@ Status _createCollection(OperationContext* opCtx,
nss,
Top::LockType::NotLocked,
AutoStatsTracker::LogMode::kUpdateTopAndCurOp,
- CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(nss.db()));
+ CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(nss.dbName()));
// If the collection creation rolls back, ensure that the Top entry created for the
// collection is deleted.
diff --git a/src/mongo/db/catalog/database_holder_impl.cpp b/src/mongo/db/catalog/database_holder_impl.cpp
index 1630f7df0a4..317c50c88ca 100644
--- a/src/mongo/db/catalog/database_holder_impl.cpp
+++ b/src/mongo/db/catalog/database_holder_impl.cpp
@@ -259,9 +259,8 @@ void DatabaseHolderImpl::dropDb(OperationContext* opCtx, Database* db) {
}
// Clean up the in-memory database state.
- CollectionCatalog::write(opCtx, [&](CollectionCatalog& catalog) {
- catalog.clearDatabaseProfileSettings(name.db());
- });
+ CollectionCatalog::write(
+ opCtx, [&](CollectionCatalog& catalog) { catalog.clearDatabaseProfileSettings(name); });
close(opCtx, name);
auto const storageEngine = serviceContext->getStorageEngine();
diff --git a/src/mongo/db/catalog/database_impl.cpp b/src/mongo/db/catalog/database_impl.cpp
index 573ed2be469..6d3a2e8b602 100644
--- a/src/mongo/db/catalog/database_impl.cpp
+++ b/src/mongo/db/catalog/database_impl.cpp
@@ -452,7 +452,7 @@ Status DatabaseImpl::dropCollection(OperationContext* opCtx,
if (nss.isSystem()) {
if (nss.isSystemDotProfile()) {
- if (catalog->getDatabaseProfileLevel(_name.db()) != 0)
+ if (catalog->getDatabaseProfileLevel(_name) != 0)
return Status(ErrorCodes::IllegalOperation,
"turn off profiling before dropping system.profile collection");
} else if (nss.isSystemDotViews()) {
diff --git a/src/mongo/db/catalog/drop_collection.cpp b/src/mongo/db/catalog/drop_collection.cpp
index eb98e44b209..c8849d06825 100644
--- a/src/mongo/db/catalog/drop_collection.cpp
+++ b/src/mongo/db/catalog/drop_collection.cpp
@@ -154,7 +154,7 @@ Status _dropView(OperationContext* opCtx,
collectionName,
Top::LockType::NotLocked,
AutoStatsTracker::LogMode::kUpdateCurOp,
- CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(collectionName.db()));
+ CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(collectionName.dbName()));
if (opCtx->writesAreReplicated() &&
!repl::ReplicationCoordinator::get(opCtx)->canAcceptWritesFor(opCtx, collectionName)) {
@@ -222,7 +222,7 @@ Status _abortIndexBuildsAndDrop(OperationContext* opCtx,
startingNss,
Top::LockType::NotLocked,
AutoStatsTracker::LogMode::kUpdateCurOp,
- CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(startingNss.db()));
+ CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(startingNss.dbName()));
IndexBuildsCoordinator* indexBuildsCoord = IndexBuildsCoordinator::get(opCtx);
const UUID collectionUUID = coll->uuid();
@@ -323,7 +323,7 @@ Status _dropCollectionForApplyOps(OperationContext* opCtx,
collectionName,
Top::LockType::NotLocked,
AutoStatsTracker::LogMode::kUpdateCurOp,
- CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(collectionName.db()));
+ CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(collectionName.dbName()));
WriteUnitOfWork wunit(opCtx);
diff --git a/src/mongo/db/catalog/rename_collection.cpp b/src/mongo/db/catalog/rename_collection.cpp
index 38066226874..e3de3e5ddd5 100644
--- a/src/mongo/db/catalog/rename_collection.cpp
+++ b/src/mongo/db/catalog/rename_collection.cpp
@@ -337,7 +337,7 @@ Status renameCollectionWithinDB(OperationContext* opCtx,
source,
Top::LockType::NotLocked,
AutoStatsTracker::LogMode::kUpdateCurOp,
- CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(source.db()));
+ CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(source.dbName()));
if (!targetColl) {
return renameCollectionDirectly(opCtx, db, sourceColl->uuid(), source, target, options);
@@ -378,7 +378,7 @@ Status renameCollectionWithinDBForApplyOps(OperationContext* opCtx,
source,
Top::LockType::NotLocked,
AutoStatsTracker::LogMode::kUpdateCurOp,
- CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(source.db()));
+ CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(source.dbName()));
return writeConflictRetry(opCtx, "renameCollection", target.ns(), [&] {
auto targetColl = CollectionCatalog::get(opCtx)->lookupCollectionByNamespace(opCtx, target);
@@ -510,7 +510,7 @@ Status renameBetweenDBs(OperationContext* opCtx,
source,
Top::LockType::NotLocked,
AutoStatsTracker::LogMode::kUpdateCurOp,
- CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(source.db()));
+ CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(source.dbName()));
auto catalog = CollectionCatalog::get(opCtx);
const auto sourceColl = catalog->lookupCollectionByNamespace(opCtx, source);
diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp
index 56fe8853d06..2b11eb23040 100644
--- a/src/mongo/db/commands/create_indexes.cpp
+++ b/src/mongo/db/commands/create_indexes.cpp
@@ -542,7 +542,7 @@ CreateIndexesReply runCreateIndexesWithCoordinator(OperationContext* opCtx,
ns,
Top::LockType::WriteLocked,
AutoStatsTracker::LogMode::kUpdateTopAndCurOp,
- CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(ns.db()));
+ CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(ns.dbName()));
auto buildUUID = UUID::gen();
ReplIndexBuildState::IndexCatalogStats stats;
diff --git a/src/mongo/db/commands/dbcommands.cpp b/src/mongo/db/commands/dbcommands.cpp
index 6fb0f9c81c9..f377df1db04 100644
--- a/src/mongo/db/commands/dbcommands.cpp
+++ b/src/mongo/db/commands/dbcommands.cpp
@@ -696,9 +696,12 @@ public:
} else {
{
stdx::lock_guard<Client> lk(*opCtx->getClient());
+ // TODO SERVER-66561: For getDatabaseProfileLevel, takes the passed in "const
+ // DatabaseName& dbname" directly.
// TODO: OldClientContext legacy, needs to be removed
CurOp::get(opCtx)->enter_inlock(
- dbname.c_str(), CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(dbname));
+ dbname.c_str(),
+ CollectionCatalog::get(opCtx)->getDatabaseProfileLevel({boost::none, dbname}));
}
db->getStats(opCtx, &result, includeFreeStorage, scale);
diff --git a/src/mongo/db/commands/dbcommands_d.cpp b/src/mongo/db/commands/dbcommands_d.cpp
index 51f03ce67ba..7512ed32615 100644
--- a/src/mongo/db/commands/dbcommands_d.cpp
+++ b/src/mongo/db/commands/dbcommands_d.cpp
@@ -102,7 +102,7 @@ MONGO_FAIL_POINT_DEFINE(waitInFilemd5DuringManualYield);
Status _setProfileSettings(OperationContext* opCtx,
Database* db,
- StringData dbName,
+ const DatabaseName& dbName,
mongo::CollectionCatalog::ProfileSettings newSettings) {
invariant(db);
@@ -150,7 +150,7 @@ public:
protected:
CollectionCatalog::ProfileSettings _applyProfilingLevel(
OperationContext* opCtx,
- const std::string& dbName,
+ const DatabaseName& dbName,
const ProfileCmdRequest& request) const final {
const auto profilingLevel = request.getCommandParameter();
@@ -168,7 +168,7 @@ protected:
// Accessing system.profile collection should not conflict with oplog application.
ShouldNotConflictWithSecondaryBatchApplicationBlock shouldNotConflictBlock(
opCtx->lockState());
- AutoGetDb ctx(opCtx, dbName, dbMode);
+ AutoGetDb ctx(opCtx, dbName.db(), dbMode);
Database* db = ctx.getDb();
// Fetches the database profiling level + filter or the server default if the db does not
@@ -180,9 +180,7 @@ protected:
// When setting the profiling level, create the database if it didn't already exist.
// When just reading the profiling level, we do not create the database.
auto databaseHolder = DatabaseHolder::get(opCtx);
- // TODO SERVER-63109 Make _setProfileSettings pass DatabaseName.
- const DatabaseName tenantDbName(boost::none, dbName);
- db = databaseHolder->openDb(opCtx, tenantDbName);
+ db = databaseHolder->openDb(opCtx, dbName);
}
auto newSettings = oldSettings;
diff --git a/src/mongo/db/commands/find_and_modify.cpp b/src/mongo/db/commands/find_and_modify.cpp
index ca77a79c7e1..6fc5b84c654 100644
--- a/src/mongo/db/commands/find_and_modify.cpp
+++ b/src/mongo/db/commands/find_and_modify.cpp
@@ -360,7 +360,7 @@ write_ops::FindAndModifyCommandReply CmdFindAndModify::Invocation::writeConflict
stdx::lock_guard<Client> lk(*opCtx->getClient());
CurOp::get(opCtx)->enter_inlock(
nsString.ns().c_str(),
- CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(nsString.db()));
+ CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(nsString.dbName()));
}
assertCanWrite_inlock(opCtx, nsString);
@@ -425,7 +425,7 @@ write_ops::FindAndModifyCommandReply CmdFindAndModify::Invocation::writeConflict
stdx::lock_guard<Client> lk(*opCtx->getClient());
CurOp::get(opCtx)->enter_inlock(
nsString.ns().c_str(),
- CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(nsString.db()));
+ CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(nsString.dbName()));
}
assertCanWrite_inlock(opCtx, nsString);
diff --git a/src/mongo/db/commands/getmore_cmd.cpp b/src/mongo/db/commands/getmore_cmd.cpp
index 7313bc4b1aa..a344ab03278 100644
--- a/src/mongo/db/commands/getmore_cmd.cpp
+++ b/src/mongo/db/commands/getmore_cmd.cpp
@@ -498,7 +498,7 @@ public:
nss,
Top::LockType::NotLocked,
AutoStatsTracker::LogMode::kUpdateTopAndCurOp,
- CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(nss.db()));
+ CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(nss.dbName()));
}
} else {
invariant(cursorPin->getExecutor()->lockPolicy() ==
@@ -528,7 +528,7 @@ public:
nss,
Top::LockType::ReadLocked,
AutoStatsTracker::LogMode::kUpdateTopAndCurOp,
- CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(nss.db()));
+ CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(nss.dbName()));
// Check whether we are allowed to read from this node after acquiring our locks.
uassertStatusOK(repl::ReplicationCoordinator::get(opCtx)->checkCanServeReadsFor(
diff --git a/src/mongo/db/commands/killcursors_cmd.cpp b/src/mongo/db/commands/killcursors_cmd.cpp
index b7ddbffb75c..c63b3e2fad9 100644
--- a/src/mongo/db/commands/killcursors_cmd.cpp
+++ b/src/mongo/db/commands/killcursors_cmd.cpp
@@ -46,11 +46,12 @@ struct KillCursorsCmd {
static Status doKillCursor(OperationContext* opCtx, const NamespaceString& nss, CursorId id) {
boost::optional<AutoStatsTracker> statsTracker;
if (!nss.isCollectionlessCursorNamespace()) {
- statsTracker.emplace(opCtx,
- nss,
- Top::LockType::NotLocked,
- AutoStatsTracker::LogMode::kUpdateTopAndCurOp,
- CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(nss.db()));
+ statsTracker.emplace(
+ opCtx,
+ nss,
+ Top::LockType::NotLocked,
+ AutoStatsTracker::LogMode::kUpdateTopAndCurOp,
+ CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(nss.dbName()));
}
auto cursorManager = CursorManager::get(opCtx);
diff --git a/src/mongo/db/commands/profile_common.cpp b/src/mongo/db/commands/profile_common.cpp
index 625fae83723..7057dba6c2e 100644
--- a/src/mongo/db/commands/profile_common.cpp
+++ b/src/mongo/db/commands/profile_common.cpp
@@ -81,9 +81,11 @@ bool ProfileCmdBase::run(OperationContext* opCtx,
*sampleRate >= 0.0 && *sampleRate <= 1.0);
}
- // Delegate to _applyProfilingLevel to set the profiling level appropriately whether we are on
- // mongoD or mongoS.
- auto oldSettings = _applyProfilingLevel(opCtx, dbName, request);
+ // TODO SERVER-66561: For _applyProfilingLevel, takes the passed in "const DatabaseName& dbName"
+ // directly.
+ // Delegate to _applyProfilingLevel to set the profiling level appropriately whether
+ // we are on mongoD or mongoS.
+ auto oldSettings = _applyProfilingLevel(opCtx, {boost::none, dbName}, request);
auto oldSlowMS = serverGlobalParams.slowMS;
auto oldSampleRate = serverGlobalParams.sampleRate;
@@ -122,10 +124,14 @@ bool ProfileCmdBase::run(OperationContext* opCtx,
}
attrs.add("from", oldState.obj());
+ // TODO SERVER-66561: For getDatabaseProfileSettings, takes the passed in "const
+ // DatabaseName& dbName" directly.
+
// newSettings.level may differ from profilingLevel: profilingLevel is part of the request,
// and if the request specifies {profile: -1, ...} then we want to show the unchanged value
// (0, 1, or 2).
- auto newSettings = CollectionCatalog::get(opCtx)->getDatabaseProfileSettings(dbName);
+ auto newSettings =
+ CollectionCatalog::get(opCtx)->getDatabaseProfileSettings({boost::none, dbName});
newState.append("level"_sd, newSettings.level);
newState.append("slowms"_sd, serverGlobalParams.slowMS);
newState.append("sampleRate"_sd, serverGlobalParams.sampleRate);
diff --git a/src/mongo/db/commands/profile_common.h b/src/mongo/db/commands/profile_common.h
index b8ffd40783e..adab840ff63 100644
--- a/src/mongo/db/commands/profile_common.h
+++ b/src/mongo/db/commands/profile_common.h
@@ -78,7 +78,7 @@ protected:
// set. On success, returns a struct indicating the previous profiling level and filter.
virtual CollectionCatalog::ProfileSettings _applyProfilingLevel(
OperationContext* opCtx,
- const std::string& dbName,
+ const DatabaseName& dbName,
const ProfileCmdRequest& request) const = 0;
};
diff --git a/src/mongo/db/db_raii.cpp b/src/mongo/db/db_raii.cpp
index b9e6bc38f46..ddc53c40db1 100644
--- a/src/mongo/db/db_raii.cpp
+++ b/src/mongo/db/db_raii.cpp
@@ -814,14 +814,14 @@ AutoGetCollectionForReadCommandBase<AutoGetCollectionForReadType>::
AutoStatsTracker::LogMode logMode,
const std::vector<NamespaceStringOrUUID>& secondaryNssOrUUIDs)
: _autoCollForRead(opCtx, nsOrUUID, viewMode, deadline, secondaryNssOrUUIDs),
- _statsTracker(
- opCtx,
- _autoCollForRead.getNss(),
- Top::LockType::ReadLocked,
- logMode,
- CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(_autoCollForRead.getNss().db()),
- deadline,
- secondaryNssOrUUIDs) {
+ _statsTracker(opCtx,
+ _autoCollForRead.getNss(),
+ Top::LockType::ReadLocked,
+ logMode,
+ CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(
+ _autoCollForRead.getNss().dbName()),
+ deadline,
+ secondaryNssOrUUIDs) {
hangBeforeAutoGetShardVersionCheck.executeIf(
[&](auto&) { hangBeforeAutoGetShardVersionCheck.pauseWhileSet(opCtx); },
@@ -904,8 +904,8 @@ OldClientContext::OldClientContext(OperationContext* opCtx, const std::string& n
}
stdx::lock_guard<Client> lk(*_opCtx->getClient());
- currentOp->enter_inlock(
- ns.c_str(), CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(_db->name().db()));
+ currentOp->enter_inlock(ns.c_str(),
+ CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(_db->name()));
}
AutoGetCollectionForReadCommandMaybeLockFree::AutoGetCollectionForReadCommandMaybeLockFree(
diff --git a/src/mongo/db/ops/write_ops_exec.cpp b/src/mongo/db/ops/write_ops_exec.cpp
index 8b63918ac42..ee703965b72 100644
--- a/src/mongo/db/ops/write_ops_exec.cpp
+++ b/src/mongo/db/ops/write_ops_exec.cpp
@@ -463,8 +463,8 @@ bool insertBatchAndHandleErrors(OperationContext* opCtx,
makeCollection(opCtx, wholeOp.getNamespace());
}
- curOp.raiseDbProfileLevel(
- CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(wholeOp.getNamespace().db()));
+ curOp.raiseDbProfileLevel(CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(
+ wholeOp.getNamespace().dbName()));
assertCanWrite_inlock(opCtx, wholeOp.getNamespace());
CurOpFailpointHelpers::waitWhileFailPointEnabled(
@@ -842,7 +842,8 @@ static SingleWriteResult performSingleUpdateOp(OperationContext* opCtx,
auto& curOp = *CurOp::get(opCtx);
if (collection->getDb()) {
- curOp.raiseDbProfileLevel(CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(ns.db()));
+ curOp.raiseDbProfileLevel(
+ CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(ns.dbName()));
}
assertCanWrite_inlock(opCtx, ns);
@@ -1174,7 +1175,8 @@ static SingleWriteResult performSingleDeleteOp(OperationContext* opCtx,
uassertStatusOK(parsedDelete.parseRequest());
if (collection.getDb()) {
- curOp.raiseDbProfileLevel(CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(ns.db()));
+ curOp.raiseDbProfileLevel(
+ CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(ns.dbName()));
}
assertCanWrite_inlock(opCtx, ns);
@@ -1325,7 +1327,7 @@ Status performAtomicTimeseriesWrites(
}
auto curOp = CurOp::get(opCtx);
- curOp->raiseDbProfileLevel(CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(ns.db()));
+ curOp->raiseDbProfileLevel(CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(ns.dbName()));
assertCanWrite_inlock(opCtx, ns);
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 ea28ec1aafe..84a4e493738 100644
--- a/src/mongo/db/repl/tenant_migration_shard_merge_util.cpp
+++ b/src/mongo/db/repl/tenant_migration_shard_merge_util.cpp
@@ -183,7 +183,7 @@ void wiredTigerImportFromBackupCursor(OperationContext* opCtx,
nss,
Top::LockType::NotLocked,
AutoStatsTracker::LogMode::kUpdateTopAndCurOp,
- catalog->getDatabaseProfileLevel(nss.db()));
+ catalog->getDatabaseProfileLevel(nss.dbName()));
// If the collection creation rolls back, ensure that the Top entry created for the
// collection is deleted.
diff --git a/src/mongo/db/s/shardsvr_collmod_command.cpp b/src/mongo/db/s/shardsvr_collmod_command.cpp
index 26065c6aa72..fda9b426f4a 100644
--- a/src/mongo/db/s/shardsvr_collmod_command.cpp
+++ b/src/mongo/db/s/shardsvr_collmod_command.cpp
@@ -110,7 +110,7 @@ public:
// profile level increase in order to be logged in "<db>.system.profile"
const auto& cmd = requestParser.request();
CurOp::get(opCtx)->raiseDbProfileLevel(
- CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(cmd.getDbName()));
+ CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(cmd.getNamespace().dbName()));
boost::optional<FixedFCVRegion> fcvRegion;
fcvRegion.emplace(opCtx);
diff --git a/src/mongo/db/s/shardsvr_drop_collection_command.cpp b/src/mongo/db/s/shardsvr_drop_collection_command.cpp
index 55d9d096121..9e7954b2d56 100644
--- a/src/mongo/db/s/shardsvr_drop_collection_command.cpp
+++ b/src/mongo/db/s/shardsvr_drop_collection_command.cpp
@@ -94,7 +94,7 @@ public:
// Since this operation is not directly writing locally we need to force its db
// profile level increase in order to be logged in "<db>.system.profile"
CurOp::get(opCtx)->raiseDbProfileLevel(
- CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(targetNs.db()));
+ CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(targetNs.dbName()));
auto coordinatorDoc = DropCollectionCoordinatorDocument();
coordinatorDoc.setShardingDDLCoordinatorMetadata(
diff --git a/src/mongo/db/s/shardsvr_drop_database_command.cpp b/src/mongo/db/s/shardsvr_drop_database_command.cpp
index 78b6941017c..7f1321f6718 100644
--- a/src/mongo/db/s/shardsvr_drop_database_command.cpp
+++ b/src/mongo/db/s/shardsvr_drop_database_command.cpp
@@ -79,7 +79,7 @@ public:
// Since this operation is not directly writing locally we need to force its db
// profile level increase in order to be logged in "<db>.system.profile"
CurOp::get(opCtx)->raiseDbProfileLevel(
- CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(request().getDbName()));
+ CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(ns().dbName()));
auto coordinatorDoc = DropDatabaseCoordinatorDocument();
coordinatorDoc.setShardingDDLCoordinatorMetadata(
diff --git a/src/mongo/db/s/shardsvr_drop_indexes_command.cpp b/src/mongo/db/s/shardsvr_drop_indexes_command.cpp
index dbaa2d591da..acbb42422b9 100644
--- a/src/mongo/db/s/shardsvr_drop_indexes_command.cpp
+++ b/src/mongo/db/s/shardsvr_drop_indexes_command.cpp
@@ -138,7 +138,7 @@ ShardsvrDropIndexesCommand::Invocation::Response ShardsvrDropIndexesCommand::Inv
// Since this operation is not directly writing locally we need to force its db profile level
// increase in order to be logged in "<db>.system.profile".
CurOp::get(opCtx)->raiseDbProfileLevel(
- CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(ns().db()));
+ CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(ns().dbName()));
DropIndexes dropIdxCmd(ns());
dropIdxCmd.setDropIndexesRequest(request().getDropIndexesRequest());
diff --git a/src/mongo/db/transaction_history_iterator.cpp b/src/mongo/db/transaction_history_iterator.cpp
index a58db70e5f1..90410064085 100644
--- a/src/mongo/db/transaction_history_iterator.cpp
+++ b/src/mongo/db/transaction_history_iterator.cpp
@@ -79,13 +79,12 @@ BSONObj findOneOplogEntry(OperationContext* opCtx,
const DatabaseName dbName(boost::none, NamespaceString::kLocalDb);
const auto localDb = DatabaseHolder::get(opCtx)->getDb(opCtx, dbName);
invariant(localDb);
- AutoStatsTracker statsTracker(
- opCtx,
- NamespaceString::kRsOplogNamespace,
- Top::LockType::ReadLocked,
- AutoStatsTracker::LogMode::kUpdateTop,
- CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(NamespaceString::kLocalDb),
- Date_t::max());
+ AutoStatsTracker statsTracker(opCtx,
+ NamespaceString::kRsOplogNamespace,
+ Top::LockType::ReadLocked,
+ AutoStatsTracker::LogMode::kUpdateTop,
+ CollectionCatalog::get(opCtx)->getDatabaseProfileLevel(dbName),
+ Date_t::max());
auto exec = uassertStatusOK(getExecutorFind(opCtx,
&oplogRead.getCollection(),
diff --git a/src/mongo/s/commands/cluster_profile_cmd.cpp b/src/mongo/s/commands/cluster_profile_cmd.cpp
index c2564c19b1d..f15e496f22e 100644
--- a/src/mongo/s/commands/cluster_profile_cmd.cpp
+++ b/src/mongo/s/commands/cluster_profile_cmd.cpp
@@ -51,7 +51,7 @@ public:
protected:
CollectionCatalog::ProfileSettings _applyProfilingLevel(
OperationContext* opCtx,
- const std::string& dbName,
+ const DatabaseName& dbName,
const ProfileCmdRequest& request) const final {
invariant(!opCtx->lockState()->isW());