summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands
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 /src/mongo/db/commands
parenteb90659062d8ac2dfd629b5d672c67423bddaa6a (diff)
downloadmongo-b065a3b04ab6c14b7a695f0c3f97eaa81b202a36.tar.gz
SERVER-63109 Change CollectionCatalog::_databaseProfileSettings to be keyed by DatabaseName
Diffstat (limited to 'src/mongo/db/commands')
-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
8 files changed, 30 insertions, 22 deletions
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;
};