summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel Marks <gabriel.marks@mongodb.com>2022-08-15 17:02:40 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-08-15 18:09:03 +0000
commit66163eb7cf262e3ae7f033bf7145a426b39559ec (patch)
treeed1c4c13a7dc45f2e224ca63ad3dd253b2da5c73 /src
parent7e08691fc9d16cc78cb2d899532ffb13a29bba77 (diff)
downloadmongo-66163eb7cf262e3ae7f033bf7145a426b39559ec.tar.gz
SERVER-68311 get/setClusterParameter invocations use tenant collection
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/commands/get_cluster_parameter_invocation.cpp16
-rw-r--r--src/mongo/db/commands/set_cluster_parameter_invocation.cpp8
-rw-r--r--src/mongo/db/commands/set_cluster_parameter_invocation.h6
-rw-r--r--src/mongo/db/commands/set_cluster_parameter_invocation_test.cpp3
-rw-r--r--src/mongo/db/namespace_string.cpp6
-rw-r--r--src/mongo/db/namespace_string.h8
-rw-r--r--src/mongo/s/commands/cluster_get_cluster_parameter_cmd.cpp1
7 files changed, 33 insertions, 15 deletions
diff --git a/src/mongo/db/commands/get_cluster_parameter_invocation.cpp b/src/mongo/db/commands/get_cluster_parameter_invocation.cpp
index f5f2b1442c6..fab07f4dca2 100644
--- a/src/mongo/db/commands/get_cluster_parameter_invocation.cpp
+++ b/src/mongo/db/commands/get_cluster_parameter_invocation.cpp
@@ -144,14 +144,14 @@ GetClusterParameterInvocation::Reply GetClusterParameterInvocation::getDurablePa
// Perform the majority read on the config server primary.
BSONObj query = queryDocBuilder.obj();
LOGV2_DEBUG(6226101, 2, "Querying config servers for cluster parameters", "query"_attr = query);
- auto findResponse = uassertStatusOK(
- configServers->exhaustiveFindOnConfig(opCtx,
- ReadPreferenceSetting{ReadPreference::PrimaryOnly},
- repl::ReadConcernLevel::kMajorityReadConcern,
- NamespaceString::kClusterParametersNamespace,
- query,
- BSONObj(),
- boost::none));
+ auto findResponse = uassertStatusOK(configServers->exhaustiveFindOnConfig(
+ opCtx,
+ ReadPreferenceSetting{ReadPreference::PrimaryOnly},
+ repl::ReadConcernLevel::kMajorityReadConcern,
+ NamespaceString::makeClusterParametersNSS(request.getDbName().tenantId()),
+ query,
+ BSONObj(),
+ boost::none));
// Any parameters that are not included in the response don't have a cluster parameter
// document yet, which means they still are using the default value.
diff --git a/src/mongo/db/commands/set_cluster_parameter_invocation.cpp b/src/mongo/db/commands/set_cluster_parameter_invocation.cpp
index 41cc56ad638..ed85f60fc76 100644
--- a/src/mongo/db/commands/set_cluster_parameter_invocation.cpp
+++ b/src/mongo/db/commands/set_cluster_parameter_invocation.cpp
@@ -64,7 +64,8 @@ bool SetClusterParameterInvocation::invoke(OperationContext* opCtx,
LOGV2_DEBUG(
6432603, 2, "Updating cluster parameter on-disk", "clusterParameter"_attr = parameterName);
- return uassertStatusOK(_dbService.updateParameterOnDisk(opCtx, query, update, writeConcern));
+ return uassertStatusOK(_dbService.updateParameterOnDisk(
+ opCtx, query, update, writeConcern, cmd.getDbName().tenantId()));
}
std::pair<BSONObj, BSONObj> SetClusterParameterInvocation::normalizeParameter(
@@ -101,7 +102,8 @@ StatusWith<bool> ClusterParameterDBClientService::updateParameterOnDisk(
OperationContext* opCtx,
BSONObj query,
BSONObj update,
- const WriteConcernOptions& writeConcern) {
+ const WriteConcernOptions& writeConcern,
+ const boost::optional<TenantId>& tenantId) {
BSONObj res;
BSONObjBuilder set;
@@ -116,7 +118,7 @@ StatusWith<bool> ClusterParameterDBClientService::updateParameterOnDisk(
NamespaceString::kConfigDb.toString(),
[&] {
write_ops::UpdateCommandRequest updateOp(
- NamespaceString::kClusterParametersNamespace);
+ NamespaceString::makeClusterParametersNSS(tenantId));
updateOp.setUpdates({[&] {
write_ops::UpdateOpEntry entry;
entry.setQ(query);
diff --git a/src/mongo/db/commands/set_cluster_parameter_invocation.h b/src/mongo/db/commands/set_cluster_parameter_invocation.h
index 3648f8e1955..f5bf46cb998 100644
--- a/src/mongo/db/commands/set_cluster_parameter_invocation.h
+++ b/src/mongo/db/commands/set_cluster_parameter_invocation.h
@@ -51,7 +51,8 @@ public:
virtual StatusWith<bool> updateParameterOnDisk(OperationContext* opCtx,
BSONObj query,
BSONObj update,
- const WriteConcernOptions&) = 0;
+ const WriteConcernOptions&,
+ const boost::optional<TenantId>&) = 0;
virtual Timestamp getUpdateClusterTime(OperationContext*) = 0;
virtual ~DBClientService() = default;
};
@@ -62,7 +63,8 @@ public:
StatusWith<bool> updateParameterOnDisk(OperationContext* opCtx,
BSONObj query,
BSONObj update,
- const WriteConcernOptions&) override;
+ const WriteConcernOptions&,
+ const boost::optional<TenantId>&) override;
Timestamp getUpdateClusterTime(OperationContext*) override;
private:
diff --git a/src/mongo/db/commands/set_cluster_parameter_invocation_test.cpp b/src/mongo/db/commands/set_cluster_parameter_invocation_test.cpp
index a2de6514420..8209b0ee330 100644
--- a/src/mongo/db/commands/set_cluster_parameter_invocation_test.cpp
+++ b/src/mongo/db/commands/set_cluster_parameter_invocation_test.cpp
@@ -101,7 +101,8 @@ public:
StatusWith<bool> updateParameterOnDisk(OperationContext* opCtx,
BSONObj cmd,
BSONObj info,
- const WriteConcernOptions&) override {
+ const WriteConcernOptions&,
+ const boost::optional<TenantId>& tenantId) override {
return updateParameterOnDiskMockImpl(cmd, info);
}
diff --git a/src/mongo/db/namespace_string.cpp b/src/mongo/db/namespace_string.cpp
index 9a79fc2f4ca..b6c95f10c6b 100644
--- a/src/mongo/db/namespace_string.cpp
+++ b/src/mongo/db/namespace_string.cpp
@@ -307,6 +307,12 @@ bool NamespaceString::mustBeAppliedInOwnOplogBatch() const {
_ns == kConfigsvrShardsNamespace.ns();
}
+NamespaceString NamespaceString::makeClusterParametersNSS(
+ const boost::optional<TenantId>& tenantId) {
+ return tenantId ? NamespaceString(tenantId, kConfigDb, "clusterParameters")
+ : kClusterParametersNamespace;
+}
+
NamespaceString NamespaceString::makeListCollectionsNSS(const DatabaseName& dbName) {
NamespaceString nss(dbName, listCollectionsCursorCol);
dassert(nss.isValid());
diff --git a/src/mongo/db/namespace_string.h b/src/mongo/db/namespace_string.h
index 18cf434bd86..20d2403bb65 100644
--- a/src/mongo/db/namespace_string.h
+++ b/src/mongo/db/namespace_string.h
@@ -224,7 +224,7 @@ public:
// Namespace used for CompactParticipantCoordinator service.
static const NamespaceString kCompactStructuredEncryptionCoordinatorNamespace;
- // Namespace used for storing cluster wide parameters.
+ // Namespace used for storing cluster wide parameters on dedicated configurations.
static const NamespaceString kClusterParametersNamespace;
// Namespace used for storing the list of shards on the CSRS.
@@ -348,6 +348,12 @@ public:
static NamespaceString makeListCollectionsNSS(const DatabaseName& dbName);
/**
+ * Constructs the cluster parameters NamespaceString for the specified tenant. The format for
+ * this namespace is "(<tenantId>_)config.clusterParameters".
+ */
+ static NamespaceString makeClusterParametersNSS(const boost::optional<TenantId>& tenantId);
+
+ /**
* NOTE: DollarInDbNameBehavior::allow is deprecated.
*
* Please use DollarInDbNameBehavior::disallow and check explicitly for any DB names that must
diff --git a/src/mongo/s/commands/cluster_get_cluster_parameter_cmd.cpp b/src/mongo/s/commands/cluster_get_cluster_parameter_cmd.cpp
index 3e741c4071b..c062456cc06 100644
--- a/src/mongo/s/commands/cluster_get_cluster_parameter_cmd.cpp
+++ b/src/mongo/s/commands/cluster_get_cluster_parameter_cmd.cpp
@@ -72,6 +72,7 @@ public:
Reply typedRun(OperationContext* opCtx) {
GetClusterParameterInvocation invocation;
+
if (gFeatureFlagClusterWideConfigM2.isEnabled(
serverGlobalParams.featureCompatibility)) {
// Refresh cached cluster server parameters via a majority read from the config