summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBilly Donahue <billy.donahue@mongodb.com>2023-02-09 21:07:54 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-02-10 00:00:58 +0000
commit332a6b7c11d58b5d9e2582bff0b2555a46ee556e (patch)
treebb1bb0461aecb62a7e986bf9d07bb6a8a7a13f33 /src
parentbb6f218ecc187c3ad5496f0e7b6ba92c621b71d0 (diff)
downloadmongo-332a6b7c11d58b5d9e2582bff0b2555a46ee556e.tar.gz
SERVER-73834 NamespaceString constants immortal and constexpr
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/namespace_string.cpp157
-rw-r--r--src/mongo/db/namespace_string.h274
-rw-r--r--src/mongo/db/namespace_string_reserved.def.h257
-rw-r--r--src/mongo/s/sessions_collection_sharded.cpp4
4 files changed, 366 insertions, 326 deletions
diff --git a/src/mongo/db/namespace_string.cpp b/src/mongo/db/namespace_string.cpp
index 6975259bca2..5eda39b5ec8 100644
--- a/src/mongo/db/namespace_string.cpp
+++ b/src/mongo/db/namespace_string.cpp
@@ -54,163 +54,6 @@ constexpr auto fle2EcocSuffix = ".ecoc"_sd;
} // namespace
-constexpr StringData NamespaceString::kAdminDb;
-constexpr StringData NamespaceString::kLocalDb;
-constexpr StringData NamespaceString::kConfigDb;
-constexpr StringData NamespaceString::kSystemDotViewsCollectionName;
-constexpr StringData NamespaceString::kSystemDotJavascriptCollectionName;
-constexpr StringData NamespaceString::kOrphanCollectionPrefix;
-constexpr StringData NamespaceString::kOrphanCollectionDb;
-
-const NamespaceString NamespaceString::kServerConfigurationNamespace(NamespaceString::kAdminDb,
- "system.version");
-const NamespaceString NamespaceString::kLogicalSessionsNamespace(NamespaceString::kConfigDb,
- "system.sessions");
-
-const NamespaceString NamespaceString::kConfigDatabasesNamespace(NamespaceString::kConfigDb,
- "databases");
-
-// Persisted state for a shard participating in a transaction or retryable write.
-const NamespaceString NamespaceString::kSessionTransactionsTableNamespace(
- NamespaceString::kConfigDb, "transactions");
-
-// Persisted state for a shard coordinating a cross-shard transaction.
-const NamespaceString NamespaceString::kTransactionCoordinatorsNamespace(
- NamespaceString::kConfigDb, "transaction_coordinators");
-
-const NamespaceString NamespaceString::kConfigsvrRestoreNamespace(NamespaceString::kLocalDb,
- "system.collections_to_restore");
-
-const NamespaceString NamespaceString::kMigrationCoordinatorsNamespace(NamespaceString::kConfigDb,
- "migrationCoordinators");
-
-const NamespaceString NamespaceString::kMigrationRecipientsNamespace(NamespaceString::kConfigDb,
- "migrationRecipients");
-
-const NamespaceString NamespaceString::kMovePrimaryRecipientNamespace(NamespaceString::kConfigDb,
- "movePrimaryRecipients");
-
-const NamespaceString NamespaceString::kTenantMigrationDonorsNamespace(NamespaceString::kConfigDb,
- "tenantMigrationDonors");
-
-const NamespaceString NamespaceString::kTenantMigrationRecipientsNamespace(
- NamespaceString::kConfigDb, "tenantMigrationRecipients");
-
-const NamespaceString NamespaceString::kTenantMigrationOplogView(
- NamespaceString::kLocalDb, "system.tenantMigration.oplogView");
-
-const NamespaceString NamespaceString::kShardSplitDonorsNamespace(NamespaceString::kConfigDb,
- "shardSplitDonors");
-
-const NamespaceString NamespaceString::kShardConfigCollectionsNamespace(NamespaceString::kConfigDb,
- "cache.collections");
-const NamespaceString NamespaceString::kShardConfigDatabasesNamespace(NamespaceString::kConfigDb,
- "cache.databases");
-const NamespaceString NamespaceString::kKeysCollectionNamespace(NamespaceString::kAdminDb,
- "system.keys");
-const NamespaceString NamespaceString::kExternalKeysCollectionNamespace(NamespaceString::kConfigDb,
- "external_validation_keys");
-const NamespaceString NamespaceString::kRsOplogNamespace(NamespaceString::kLocalDb, "oplog.rs");
-const NamespaceString NamespaceString::kSystemReplSetNamespace(NamespaceString::kLocalDb,
- "system.replset");
-const NamespaceString NamespaceString::kLastVoteNamespace(NamespaceString::kLocalDb,
- "replset.election");
-const NamespaceString NamespaceString::kIndexBuildEntryNamespace(NamespaceString::kConfigDb,
- "system.indexBuilds");
-const NamespaceString NamespaceString::kRangeDeletionNamespace(NamespaceString::kConfigDb,
- "rangeDeletions");
-const NamespaceString NamespaceString::kRangeDeletionForRenameNamespace(NamespaceString::kConfigDb,
- "rangeDeletionsForRename");
-const NamespaceString NamespaceString::kConfigReshardingOperationsNamespace(
- NamespaceString::kConfigDb, "reshardingOperations");
-
-const NamespaceString NamespaceString::kDonorReshardingOperationsNamespace(
- NamespaceString::kConfigDb, "localReshardingOperations.donor");
-
-const NamespaceString NamespaceString::kRecipientReshardingOperationsNamespace(
- NamespaceString::kConfigDb, "localReshardingOperations.recipient");
-
-const NamespaceString NamespaceString::kShardingDDLCoordinatorsNamespace(
- NamespaceString::kConfigDb, "system.sharding_ddl_coordinators");
-
-const NamespaceString NamespaceString::kShardingRenameParticipantsNamespace(
- NamespaceString::kConfigDb, "localRenameParticipants");
-
-const NamespaceString NamespaceString::kConfigSettingsNamespace(NamespaceString::kConfigDb,
- "settings");
-
-const NamespaceString NamespaceString::kVectorClockNamespace(NamespaceString::kConfigDb,
- "vectorClock");
-
-const NamespaceString NamespaceString::kReshardingApplierProgressNamespace(
- NamespaceString::kConfigDb, "localReshardingOperations.recipient.progress_applier");
-
-const NamespaceString NamespaceString::kReshardingTxnClonerProgressNamespace(
- NamespaceString::kConfigDb, "localReshardingOperations.recipient.progress_txn_cloner");
-
-const NamespaceString NamespaceString::kCollectionCriticalSectionsNamespace(
- NamespaceString::kConfigDb, "collection_critical_sections");
-
-const NamespaceString NamespaceString::kForceOplogBatchBoundaryNamespace(
- NamespaceString::kConfigDb, "system.forceOplogBatchBoundary");
-
-const NamespaceString NamespaceString::kConfigImagesNamespace(NamespaceString::kConfigDb,
- "image_collection");
-
-const NamespaceString NamespaceString::kConfigsvrCoordinatorsNamespace(
- NamespaceString::kConfigDb, "sharding_configsvr_coordinators");
-
-const NamespaceString NamespaceString::kUserWritesCriticalSectionsNamespace(
- NamespaceString::kConfigDb, "user_writes_critical_sections");
-
-const NamespaceString NamespaceString::kCompactStructuredEncryptionCoordinatorNamespace(
- NamespaceString::kConfigDb, "compact_structured_encryption_coordinator");
-
-const NamespaceString NamespaceString::kClusterParametersNamespace(NamespaceString::kConfigDb,
- "clusterParameters");
-
-const NamespaceString NamespaceString::kConfigsvrShardsNamespace(NamespaceString::kConfigDb,
- "shards");
-
-const NamespaceString NamespaceString::kConfigsvrCollectionsNamespace(NamespaceString::kConfigDb,
- "collections");
-
-const NamespaceString NamespaceString::kConfigsvrIndexCatalogNamespace(NamespaceString::kConfigDb,
- "csrs.indexes");
-
-const NamespaceString NamespaceString::kShardIndexCatalogNamespace(NamespaceString::kConfigDb,
- "shard.indexes");
-
-const NamespaceString NamespaceString::kShardCollectionCatalogNamespace(NamespaceString::kConfigDb,
- "shard.collections");
-
-const NamespaceString NamespaceString::kConfigsvrPlacementHistoryNamespace(
- NamespaceString::kConfigDb, "placementHistory");
-
-const NamespaceString NamespaceString::kConfigsvrPlacementHistoryFcvMarkerNamespace("",
- "",
- boost::none);
-
-const NamespaceString NamespaceString::kLockpingsNamespace(NamespaceString::kConfigDb, "lockpings");
-const NamespaceString NamespaceString::kDistLocksNamepsace(NamespaceString::kConfigDb, "locks");
-
-const NamespaceString NamespaceString::kSetChangeStreamStateCoordinatorNamespace(
- NamespaceString::kConfigDb, "change_stream_coordinator");
-
-const NamespaceString NamespaceString::kGlobalIndexClonerNamespace(
- NamespaceString::kConfigDb, "localGlobalIndexOperations.cloner");
-
-const NamespaceString NamespaceString::kConfigQueryAnalyzersNamespace(NamespaceString::kConfigDb,
- "queryAnalyzers");
-
-const NamespaceString NamespaceString::kConfigSampledQueriesNamespace(NamespaceString::kConfigDb,
- "sampledQueries");
-
-const NamespaceString NamespaceString::kConfigSampledQueriesDiffNamespace(
- NamespaceString::kConfigDb, "sampledQueriesDiff");
-
-const NamespaceString NamespaceString::kLocalHealthLogNamespace(NamespaceString::kLocalDb,
- "system.healthlog");
NamespaceString NamespaceString::parseFromStringExpectTenantIdInMultitenancyMode(StringData ns) {
if (!gMultitenancySupport) {
diff --git a/src/mongo/db/namespace_string.h b/src/mongo/db/namespace_string.h
index 3b698615cef..c815564e27e 100644
--- a/src/mongo/db/namespace_string.h
+++ b/src/mongo/db/namespace_string.h
@@ -32,6 +32,7 @@
#include <algorithm>
#include <boost/optional.hpp>
#include <iosfwd>
+#include <mutex>
#include <string>
#include "mongo/base/status_with.h"
@@ -49,6 +50,79 @@ namespace mongo {
class NamespaceString {
public:
+ /**
+ * The NamespaceString reserved constants are actually this `ConstantProxy`
+ * type, which can be `constexpr` and can be used directly in place of
+ * `NamespaceString`, except in very rare cases. To work around those, use a
+ * `static_cast<const NamespaceString&>`. The first time it's used, a
+ * `ConstantProxy` produces a memoized `const NamespaceString*` and retains
+ * it for future uses.
+ */
+ class ConstantProxy {
+ public:
+ /**
+ * `ConstantProxy` objects can be copied, so that they behave more like
+ * `NamespaceString`. All copies will point to the same `SharedState`.
+ * The `SharedState` is meant to be defined constexpr, but has mutable
+ * data members to implement the on-demand memoization of the
+ * `NamespaceString`.
+ */
+ class SharedState {
+ public:
+ constexpr SharedState(StringData db, StringData coll) : _db{db}, _coll{coll} {}
+
+ const NamespaceString& get() const {
+ std::call_once(_once, [this] { _nss = new NamespaceString{_db, _coll}; });
+ return *_nss;
+ }
+
+ StringData _db;
+ StringData _coll;
+ mutable std::once_flag _once;
+ mutable const NamespaceString* _nss = nullptr;
+ };
+
+ constexpr explicit ConstantProxy(const SharedState* sharedState)
+ : _sharedState{sharedState} {}
+
+ operator const NamespaceString&() const {
+ return _get();
+ }
+
+ decltype(auto) ns() const {
+ return _get().ns();
+ }
+ decltype(auto) db() const {
+ return _get().db();
+ }
+ decltype(auto) coll() const {
+ return _get().coll();
+ }
+ decltype(auto) tenantId() const {
+ return _get().tenantId();
+ }
+ decltype(auto) dbName() const {
+ return _get().dbName();
+ }
+ decltype(auto) toString() const {
+ return _get().toString();
+ }
+
+ friend std::ostream& operator<<(std::ostream& stream, const ConstantProxy& nss) {
+ return stream << nss.toString();
+ }
+ friend StringBuilder& operator<<(StringBuilder& builder, const ConstantProxy& nss) {
+ return builder << nss.toString();
+ }
+
+ private:
+ const NamespaceString& _get() const {
+ return _sharedState->get();
+ }
+
+ const SharedState* _sharedState;
+ };
+
constexpr static size_t MaxDatabaseNameLen =
128; // max str len for the db name, including null char
constexpr static size_t MaxNSCollectionLenFCV42 = 120U;
@@ -124,176 +198,19 @@ public:
static constexpr StringData kAnalyzeShardKeySplitPointsCollectionPrefix =
"analyzeShardKey.splitPoints."_sd;
- // Namespace for storing configuration data, which needs to be replicated if the server is
- // running as a replica set. Documents in this collection should represent some configuration
- // state of the server, which needs to be recovered/consulted at startup. Each document in this
- // namespace should have its _id set to some string, which meaningfully describes what it
- // represents. For example, 'shardIdentity' and 'featureCompatibilityVersion'.
- static const NamespaceString kServerConfigurationNamespace;
-
- // Namespace for storing the logical sessions information
- static const NamespaceString kLogicalSessionsNamespace;
-
- // Namespace for storing databases information
- static const NamespaceString kConfigDatabasesNamespace;
-
- // Namespace for storing the transaction information for each session
- static const NamespaceString kSessionTransactionsTableNamespace;
-
- // Name for a shard's collections metadata collection, each document of which indicates the
- // state of a specific collection
- static const NamespaceString kShardConfigCollectionsNamespace;
-
- // Name for a shard's databases metadata collection, each document of which indicates the state
- // of a specific database
- static const NamespaceString kShardConfigDatabasesNamespace;
-
- // Namespace for storing keys for signing and validating cluster times created by the cluster
- // that this node is in.
- static const NamespaceString kKeysCollectionNamespace;
-
- // Namespace for storing keys for validating cluster times created by other clusters.
- static const NamespaceString kExternalKeysCollectionNamespace;
-
- // Namespace of the the oplog collection.
- static const NamespaceString kRsOplogNamespace;
-
- // Namespace for storing the persisted state of transaction coordinators.
- static const NamespaceString kTransactionCoordinatorsNamespace;
-
- // Namespace for storing the persisted state of migration coordinators.
- static const NamespaceString kMigrationCoordinatorsNamespace;
-
- // Namespace for storing the persisted state of migration recipients.
- static const NamespaceString kMigrationRecipientsNamespace;
-
- // Namespace for storing the persisted state of movePrimary operation recipients.
- static const NamespaceString kMovePrimaryRecipientNamespace;
-
- // Namespace for storing the persisted state of tenant migration donors.
- static const NamespaceString kTenantMigrationDonorsNamespace;
-
- // Namespace for storing the persisted state of tenant migration recipient service instances.
- static const NamespaceString kTenantMigrationRecipientsNamespace;
-
- // Namespace for view on local.oplog.rs for tenant migrations.
- static const NamespaceString kTenantMigrationOplogView;
-
- // Namespace for storing the persisted state of tenant split donors.
- static const NamespaceString kShardSplitDonorsNamespace;
-
- // Namespace for replica set configuration settings.
- static const NamespaceString kSystemReplSetNamespace;
-
- // Namespace for storing the last replica set election vote.
- static const NamespaceString kLastVoteNamespace;
- // Namespace for index build entries.
- static const NamespaceString kIndexBuildEntryNamespace;
+ // Maintainers Note: The large set of `NamespaceString`-typed static data
+ // members of the `NamespaceString` class representing system-reserved
+ // collections is now generated from "namespace_string_reserved.def.h".
+ // Please make edits there to add or change such constants.
- // Namespace for pending range deletions.
- static const NamespaceString kRangeDeletionNamespace;
-
- // Namespace containing pending range deletions snapshots for rename operations.
- static const NamespaceString kRangeDeletionForRenameNamespace;
-
- // Namespace for the coordinator's resharding operation state.
- static const NamespaceString kConfigReshardingOperationsNamespace;
-
- // Namespace for the donor shard's local resharding operation state.
- static const NamespaceString kDonorReshardingOperationsNamespace;
-
- // Namespace for the recipient shard's local resharding operation state.
- static const NamespaceString kRecipientReshardingOperationsNamespace;
-
- // Namespace for persisting sharding DDL coordinators state documents
- static const NamespaceString kShardingDDLCoordinatorsNamespace;
-
- // Namespace for persisting sharding DDL rename participant state documents
- static const NamespaceString kShardingRenameParticipantsNamespace;
-
- // Namespace for balancer settings and default read and write concerns.
- static const NamespaceString kConfigSettingsNamespace;
-
- // Namespace for vector clock state.
- static const NamespaceString kVectorClockNamespace;
-
- // Namespace for storing oplog applier progress for resharding.
- static const NamespaceString kReshardingApplierProgressNamespace;
-
- // Namespace for storing config.transactions cloner progress for resharding.
- static const NamespaceString kReshardingTxnClonerProgressNamespace;
-
- // Namespace for storing config.collectionCriticalSections documents
- static const NamespaceString kCollectionCriticalSectionsNamespace;
-
- // Dummy namespace used for forcing secondaries to handle an oplog entry on its own batch.
- static const NamespaceString kForceOplogBatchBoundaryNamespace;
-
- // Namespace used for storing retryable findAndModify images.
- static const NamespaceString kConfigImagesNamespace;
-
- // Namespace used for persisting ConfigsvrCoordinator state documents.
- static const NamespaceString kConfigsvrCoordinatorsNamespace;
-
- // Namespace for storing user write blocking critical section documents
- static const NamespaceString kUserWritesCriticalSectionsNamespace;
-
- // Namespace used during the recovery procedure for the config server.
- static const NamespaceString kConfigsvrRestoreNamespace;
-
- // Namespace used for CompactParticipantCoordinator service.
- static const NamespaceString kCompactStructuredEncryptionCoordinatorNamespace;
-
- // 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.
- static const NamespaceString kConfigsvrShardsNamespace;
-
- // Namespace used for storing the list of sharded collections on the CSRS.
- static const NamespaceString kConfigsvrCollectionsNamespace;
-
- // Namespace used for storing the index catalog on the CSRS.
- static const NamespaceString kConfigsvrIndexCatalogNamespace;
-
- // Namespace used for storing the index catalog on the shards.
- static const NamespaceString kShardIndexCatalogNamespace;
-
- // Namespace used for storing the collection catalog on the shards.
- static const NamespaceString kShardCollectionCatalogNamespace;
-
- // Namespace used for storing NamespacePlacementType docs on the CSRS.
- static const NamespaceString kConfigsvrPlacementHistoryNamespace;
-
- // Namespace value used to identify the "fcv marker entry" of
- // kConfigsvrPlacementHistoryNamespace collection which marks the start or the end of a FCV
- // upgrade/downgrade.
- static const NamespaceString kConfigsvrPlacementHistoryFcvMarkerNamespace;
-
- // TODO SERVER-68551: remove once 7.0 becomes last-lts
- static const NamespaceString kLockpingsNamespace;
-
- // TODO SERVER-68551: remove once 7.0 becomes last-lts
- static const NamespaceString kDistLocksNamepsace;
-
- // Namespace used to store the state document of 'SetChangeStreamStateCoordinator'.
- static const NamespaceString kSetChangeStreamStateCoordinatorNamespace;
-
- // Namespace used for storing global index cloner state documents.
- static const NamespaceString kGlobalIndexClonerNamespace;
-
- // Namespace used for storing query analyzer settings.
- static const NamespaceString kConfigQueryAnalyzersNamespace;
-
- // Namespace used for storing sampled queries.
- static const NamespaceString kConfigSampledQueriesNamespace;
-
- // Namespace used for storing the diffs for sampled update queries.
- static const NamespaceString kConfigSampledQueriesDiffNamespace;
-
- // Namespace used for the health log.
- static const NamespaceString kLocalHealthLogNamespace;
+ // The constants are declared as merely `const` but have `constexpr`
+ // definitions below. Because the `NamespaceString` class enclosing their
+ // type is incomplete, they can't be _declared_ fully constexpr (a constexpr
+ // limitation).
+#define NSS_CONSTANT(id, db, coll) static const ConstantProxy id;
+#include "namespace_string_reserved.def.h"
+#undef NSS_CONSTANT
/**
* Constructs an empty NamespaceString.
@@ -836,6 +753,8 @@ class NamespaceStringOrUUID {
public:
NamespaceStringOrUUID() = delete;
NamespaceStringOrUUID(NamespaceString nss) : _nss(std::move(nss)) {}
+ NamespaceStringOrUUID(const NamespaceString::ConstantProxy& nss)
+ : NamespaceStringOrUUID{static_cast<const NamespaceString&>(nss)} {}
NamespaceStringOrUUID(DatabaseName dbname, UUID uuid)
: _uuid(std::move(uuid)), _dbname(std::move(dbname)) {}
NamespaceStringOrUUID(boost::optional<TenantId> tenantId, std::string db, UUID uuid)
@@ -1033,4 +952,23 @@ inline bool NamespaceString::validCollectionName(StringData coll) {
return true;
}
+// Here are the `constexpr` definitions for the `NamespaceString::ConstantProxy`
+// constant static data members of `NamespaceString`. They cannot be defined
+// `constexpr` inside the class definition, but they can be upgraded to
+// `constexpr` here below it. Each one needs to be initialized with the address
+// of their associated shared state, so those are all defined first, as
+// variables named by the same `id`, but in separate nested namespace.
+namespace nss_detail::const_proxy_shared_states {
+#define NSS_CONSTANT(id, db, coll) \
+ constexpr inline NamespaceString::ConstantProxy::SharedState id{db, coll};
+#include "namespace_string_reserved.def.h"
+#undef NSS_CONSTANT
+} // namespace nss_detail::const_proxy_shared_states
+
+#define NSS_CONSTANT(id, db, coll) \
+ constexpr inline NamespaceString::ConstantProxy NamespaceString::id{ \
+ &nss_detail::const_proxy_shared_states::id};
+#include "namespace_string_reserved.def.h"
+#undef NSS_CONSTANT
+
} // namespace mongo
diff --git a/src/mongo/db/namespace_string_reserved.def.h b/src/mongo/db/namespace_string_reserved.def.h
new file mode 100644
index 00000000000..20e39384ee3
--- /dev/null
+++ b/src/mongo/db/namespace_string_reserved.def.h
@@ -0,0 +1,257 @@
+/**
+ * Copyright (C) 2023-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.
+ */
+
+/**
+ * This file is included multiple times into `namespace_string.h`, in order to
+ * define NamespaceString constexpr values. The `NSS_CONSTANT` macro callback
+ * will be defined differently at each include. Lines here are of the form:
+ *
+ * NSS_CONSTANT(id, db, coll)
+ *
+ * - `id` is the `ConstantProxy` data member of `NamespaceString` being defined.
+ * - `db` : must be a constexpr StringData expression.
+ * - `coll` must be a constexpr StringData expression.
+ */
+
+// Namespace for storing configuration data, which needs to be replicated if the server is
+// running as a replica set. Documents in this collection should represent some configuration
+// state of the server, which needs to be recovered/consulted at startup. Each document in this
+// namespace should have its _id set to some string, which meaningfully describes what it
+// represents. For example, 'shardIdentity' and 'featureCompatibilityVersion'.
+NSS_CONSTANT(kServerConfigurationNamespace, NamespaceString::kAdminDb, "system.version"_sd)
+
+// Namespace for storing the logical sessions information
+NSS_CONSTANT(kLogicalSessionsNamespace, NamespaceString::kConfigDb, "system.sessions"_sd)
+
+// Namespace for storing databases information
+NSS_CONSTANT(kConfigDatabasesNamespace, NamespaceString::kConfigDb, "databases"_sd)
+
+// Namespace for storing the transaction information for each session
+NSS_CONSTANT(kSessionTransactionsTableNamespace, NamespaceString::kConfigDb, "transactions"_sd)
+
+// Name for a shard's collections metadata collection, each document of which indicates the
+// state of a specific collection
+NSS_CONSTANT(kShardConfigCollectionsNamespace, NamespaceString::kConfigDb, "cache.collections"_sd)
+
+// Name for a shard's databases metadata collection, each document of which indicates the state
+// of a specific database
+NSS_CONSTANT(kShardConfigDatabasesNamespace, NamespaceString::kConfigDb, "cache.databases"_sd)
+
+// Namespace for storing keys for signing and validating cluster times created by the cluster
+// that this node is in.
+NSS_CONSTANT(kKeysCollectionNamespace, NamespaceString::kAdminDb, "system.keys"_sd)
+
+// Namespace for storing keys for validating cluster times created by other clusters.
+NSS_CONSTANT(kExternalKeysCollectionNamespace,
+ NamespaceString::kConfigDb,
+ "external_validation_keys"_sd)
+
+// Namespace of the the oplog collection.
+NSS_CONSTANT(kRsOplogNamespace, NamespaceString::kLocalDb, "oplog.rs"_sd)
+
+// Namespace for storing the persisted state of transaction coordinators.
+NSS_CONSTANT(kTransactionCoordinatorsNamespace,
+ NamespaceString::kConfigDb,
+ "transaction_coordinators"_sd)
+
+// Namespace for storing the persisted state of migration coordinators.
+NSS_CONSTANT(kMigrationCoordinatorsNamespace,
+ NamespaceString::kConfigDb,
+ "migrationCoordinators"_sd)
+
+// Namespace for storing the persisted state of migration recipients.
+NSS_CONSTANT(kMigrationRecipientsNamespace, NamespaceString::kConfigDb, "migrationRecipients"_sd)
+
+// Namespace for storing the persisted state of movePrimary operation recipients.
+NSS_CONSTANT(kMovePrimaryRecipientNamespace, NamespaceString::kConfigDb, "movePrimaryRecipients"_sd)
+
+// Namespace for storing the persisted state of tenant migration donors.
+NSS_CONSTANT(kTenantMigrationDonorsNamespace,
+ NamespaceString::kConfigDb,
+ "tenantMigrationDonors"_sd)
+
+// Namespace for storing the persisted state of tenant migration recipient service instances.
+NSS_CONSTANT(kTenantMigrationRecipientsNamespace,
+ NamespaceString::kConfigDb,
+ "tenantMigrationRecipients"_sd)
+
+// Namespace for view on local.oplog.rs for tenant migrations.
+NSS_CONSTANT(kTenantMigrationOplogView,
+ NamespaceString::kLocalDb,
+ "system.tenantMigration.oplogView"_sd)
+
+// Namespace for storing the persisted state of tenant split donors.
+NSS_CONSTANT(kShardSplitDonorsNamespace, NamespaceString::kConfigDb, "shardSplitDonors"_sd)
+
+// Namespace for replica set configuration settings.
+NSS_CONSTANT(kSystemReplSetNamespace, NamespaceString::kLocalDb, "system.replset"_sd)
+
+// Namespace for storing the last replica set election vote.
+NSS_CONSTANT(kLastVoteNamespace, NamespaceString::kLocalDb, "replset.election"_sd)
+
+// Namespace for index build entries.
+NSS_CONSTANT(kIndexBuildEntryNamespace, NamespaceString::kConfigDb, "system.indexBuilds"_sd)
+
+// Namespace for pending range deletions.
+NSS_CONSTANT(kRangeDeletionNamespace, NamespaceString::kConfigDb, "rangeDeletions"_sd)
+
+// Namespace containing pending range deletions snapshots for rename operations.
+NSS_CONSTANT(kRangeDeletionForRenameNamespace,
+ NamespaceString::kConfigDb,
+ "rangeDeletionsForRename"_sd)
+
+// Namespace for the coordinator's resharding operation state.
+NSS_CONSTANT(kConfigReshardingOperationsNamespace,
+ NamespaceString::kConfigDb,
+ "reshardingOperations"_sd)
+
+// Namespace for the donor shard's local resharding operation state.
+NSS_CONSTANT(kDonorReshardingOperationsNamespace,
+ NamespaceString::kConfigDb,
+ "localReshardingOperations.donor"_sd)
+
+// Namespace for the recipient shard's local resharding operation state.
+NSS_CONSTANT(kRecipientReshardingOperationsNamespace,
+ NamespaceString::kConfigDb,
+ "localReshardingOperations.recipient"_sd)
+
+// Namespace for persisting sharding DDL coordinators state documents
+NSS_CONSTANT(kShardingDDLCoordinatorsNamespace,
+ NamespaceString::kConfigDb,
+ "system.sharding_ddl_coordinators"_sd)
+
+// Namespace for persisting sharding DDL rename participant state documents
+NSS_CONSTANT(kShardingRenameParticipantsNamespace,
+ NamespaceString::kConfigDb,
+ "localRenameParticipants"_sd)
+
+// Namespace for balancer settings and default read and write concerns.
+NSS_CONSTANT(kConfigSettingsNamespace, NamespaceString::kConfigDb, "settings"_sd)
+
+// Namespace for vector clock state.
+NSS_CONSTANT(kVectorClockNamespace, NamespaceString::kConfigDb, "vectorClock"_sd)
+
+// Namespace for storing oplog applier progress for resharding.
+NSS_CONSTANT(kReshardingApplierProgressNamespace,
+ NamespaceString::kConfigDb,
+ "localReshardingOperations.recipient.progress_applier"_sd)
+
+// Namespace for storing config.transactions cloner progress for resharding.
+NSS_CONSTANT(kReshardingTxnClonerProgressNamespace,
+ NamespaceString::kConfigDb,
+ "localReshardingOperations.recipient.progress_txn_cloner"_sd)
+
+// Namespace for storing config.collectionCriticalSections documents
+NSS_CONSTANT(kCollectionCriticalSectionsNamespace,
+ NamespaceString::kConfigDb,
+ "collection_critical_sections"_sd)
+
+// Dummy namespace used for forcing secondaries to handle an oplog entry on its own batch.
+NSS_CONSTANT(kForceOplogBatchBoundaryNamespace,
+ NamespaceString::kConfigDb,
+ "system.forceOplogBatchBoundary"_sd)
+
+// Namespace used for storing retryable findAndModify images.
+NSS_CONSTANT(kConfigImagesNamespace, NamespaceString::kConfigDb, "image_collection"_sd)
+
+// Namespace used for persisting ConfigsvrCoordinator state documents.
+NSS_CONSTANT(kConfigsvrCoordinatorsNamespace,
+ NamespaceString::kConfigDb,
+ "sharding_configsvr_coordinators"_sd)
+
+// Namespace for storing user write blocking critical section documents
+NSS_CONSTANT(kUserWritesCriticalSectionsNamespace,
+ NamespaceString::kConfigDb,
+ "user_writes_critical_sections"_sd)
+
+// Namespace used during the recovery procedure for the config server.
+NSS_CONSTANT(kConfigsvrRestoreNamespace,
+ NamespaceString::kLocalDb,
+ "system.collections_to_restore"_sd)
+
+// Namespace used for CompactParticipantCoordinator service.
+NSS_CONSTANT(kCompactStructuredEncryptionCoordinatorNamespace,
+ NamespaceString::kConfigDb,
+ "compact_structured_encryption_coordinator"_sd)
+
+// Namespace used for storing cluster wide parameters on dedicated configurations.
+NSS_CONSTANT(kClusterParametersNamespace, NamespaceString::kConfigDb, "clusterParameters"_sd)
+
+// Namespace used for storing the list of shards on the CSRS.
+NSS_CONSTANT(kConfigsvrShardsNamespace, NamespaceString::kConfigDb, "shards"_sd)
+
+// Namespace used for storing the list of sharded collections on the CSRS.
+NSS_CONSTANT(kConfigsvrCollectionsNamespace, NamespaceString::kConfigDb, "collections"_sd)
+
+// Namespace used for storing the index catalog on the CSRS.
+NSS_CONSTANT(kConfigsvrIndexCatalogNamespace, NamespaceString::kConfigDb, "csrs.indexes"_sd)
+
+// Namespace used for storing the index catalog on the shards.
+NSS_CONSTANT(kShardIndexCatalogNamespace, NamespaceString::kConfigDb, "shard.indexes"_sd)
+
+// Namespace used for storing the collection catalog on the shards.
+NSS_CONSTANT(kShardCollectionCatalogNamespace, NamespaceString::kConfigDb, "shard.collections"_sd)
+
+// Namespace used for storing NamespacePlacementType docs on the CSRS.
+NSS_CONSTANT(kConfigsvrPlacementHistoryNamespace, NamespaceString::kConfigDb, "placementHistory"_sd)
+
+// Namespace value used to identify the "fcv marker entry" of
+// kConfigsvrPlacementHistoryNamespace collection which marks the start or the end of a FCV
+// upgrade/downgrade.
+NSS_CONSTANT(kConfigsvrPlacementHistoryFcvMarkerNamespace, StringData{}, StringData{})
+
+// TODO SERVER-68551: remove once 7.0 becomes last-lts
+NSS_CONSTANT(kLockpingsNamespace, NamespaceString::kConfigDb, "lockpings"_sd)
+
+// TODO SERVER-68551: remove once 7.0 becomes last-lts
+NSS_CONSTANT(kDistLocksNamepsace, NamespaceString::kConfigDb, "locks"_sd)
+
+// Namespace used to store the state document of 'SetChangeStreamStateCoordinator'.
+NSS_CONSTANT(kSetChangeStreamStateCoordinatorNamespace,
+ NamespaceString::kConfigDb,
+ "change_stream_coordinator"_sd)
+
+// Namespace used for storing global index cloner state documents.
+NSS_CONSTANT(kGlobalIndexClonerNamespace,
+ NamespaceString::kConfigDb,
+ "localGlobalIndexOperations.cloner"_sd)
+
+// Namespace used for storing query analyzer settings.
+NSS_CONSTANT(kConfigQueryAnalyzersNamespace, NamespaceString::kConfigDb, "queryAnalyzers"_sd)
+
+// Namespace used for storing sampled queries.
+NSS_CONSTANT(kConfigSampledQueriesNamespace, NamespaceString::kConfigDb, "sampledQueries"_sd)
+
+// Namespace used for storing the diffs for sampled update queries.
+NSS_CONSTANT(kConfigSampledQueriesDiffNamespace,
+ NamespaceString::kConfigDb,
+ "sampledQueriesDiff"_sd)
+
+// Namespace used for the health log.
+NSS_CONSTANT(kLocalHealthLogNamespace, NamespaceString::kLocalDb, "system.healthlog"_sd)
diff --git a/src/mongo/s/sessions_collection_sharded.cpp b/src/mongo/s/sessions_collection_sharded.cpp
index 642bcae0aba..b2504a90e73 100644
--- a/src/mongo/s/sessions_collection_sharded.cpp
+++ b/src/mongo/s/sessions_collection_sharded.cpp
@@ -172,7 +172,9 @@ LogicalSessionIdSet SessionsCollectionSharded::findRemovedSessions(
OpMsgRequest::fromDBAndBody(NamespaceString::kLogicalSessionsNamespace.db(), toSend)
.body;
auto findCommand = query_request_helper::makeFromFindCommand(
- toSend, NamespaceString::kLogicalSessionsNamespace, apiStrict);
+ toSend,
+ static_cast<const NamespaceString&>(NamespaceString::kLogicalSessionsNamespace),
+ apiStrict);
const boost::intrusive_ptr<ExpressionContext> expCtx;
auto cq = uassertStatusOK(