diff options
| author | Sophia Tan <sophia_tll@hotmail.com> | 2023-04-18 07:41:17 +0000 |
|---|---|---|
| committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-04-18 08:57:59 +0000 |
| commit | 274cb477d2a1b64ac81b85e9f1b3172387ce0184 (patch) | |
| tree | e89f778fa52a40413403b6a125b69271cf8469c0 /src/mongo/db/session | |
| parent | 8863b04c282557081cf2634bce0e26f4fa5389b2 (diff) | |
| download | mongo-274cb477d2a1b64ac81b85e9f1b3172387ce0184.tar.gz | |
SERVER-74486 Always include tenant in collection name attributes in error messages
Diffstat (limited to 'src/mongo/db/session')
| -rw-r--r-- | src/mongo/db/session/session_catalog_mongod.cpp | 28 | ||||
| -rw-r--r-- | src/mongo/db/session/sessions_collection_rs.cpp | 7 | ||||
| -rw-r--r-- | src/mongo/db/session/sessions_collection_standalone.cpp | 14 |
3 files changed, 28 insertions, 21 deletions
diff --git a/src/mongo/db/session/session_catalog_mongod.cpp b/src/mongo/db/session/session_catalog_mongod.cpp index ea467cf0e67..5acb0ce4d2f 100644 --- a/src/mongo/db/session/session_catalog_mongod.cpp +++ b/src/mongo/db/session/session_catalog_mongod.cpp @@ -126,9 +126,10 @@ void disallowDirectWritesUnderSession(OperationContext* opCtx) { bool isReplSet = replCoord->getReplicationMode() == repl::ReplicationCoordinator::modeReplSet; if (isReplSet) { uassert(40528, - str::stream() << "Direct writes against " - << NamespaceString::kSessionTransactionsTableNamespace - << " cannot be performed using a transaction or on a session.", + str::stream() + << "Direct writes against " + << NamespaceString::kSessionTransactionsTableNamespace.toStringForErrorMsg() + << " cannot be performed using a transaction or on a session.", !opCtx->getLogicalSessionId()); } } @@ -377,11 +378,12 @@ void createTransactionTable(OperationContext* opCtx) { // empty collection. This can happen after a failover because the collection and index // creation are recorded as separate oplog entries. } else { - uassertStatusOKWithContext(createCollectionStatus, - str::stream() - << "Failed to create the " - << NamespaceString::kSessionTransactionsTableNamespace.ns() - << " collection"); + uassertStatusOKWithContext( + createCollectionStatus, + str::stream() + << "Failed to create the " + << NamespaceString::kSessionTransactionsTableNamespace.toStringForErrorMsg() + << " collection"); } auto indexSpec = MongoDSessionCatalog::getConfigTxnPartialIndexSpec(); @@ -391,7 +393,8 @@ void createTransactionTable(OperationContext* opCtx) { uassertStatusOKWithContext( createIndexStatus, str::stream() << "Failed to create partial index for the " - << NamespaceString::kSessionTransactionsTableNamespace.ns() << " collection"); + << NamespaceString::kSessionTransactionsTableNamespace.toStringForErrorMsg() + << " collection"); } void createRetryableFindAndModifyTable(OperationContext* opCtx) { @@ -404,9 +407,10 @@ void createRetryableFindAndModifyTable(OperationContext* opCtx) { } uassertStatusOKWithContext(status, - str::stream() << "Failed to create the " - << NamespaceString::kConfigImagesNamespace.ns() - << " collection"); + str::stream() + << "Failed to create the " + << NamespaceString::kConfigImagesNamespace.toStringForErrorMsg() + << " collection"); } diff --git a/src/mongo/db/session/sessions_collection_rs.cpp b/src/mongo/db/session/sessions_collection_rs.cpp index 037af5c01e8..92a1afd26cc 100644 --- a/src/mongo/db/session/sessions_collection_rs.cpp +++ b/src/mongo/db/session/sessions_collection_rs.cpp @@ -154,7 +154,8 @@ void SessionsCollectionRS::checkSessionsCollectionExists(OperationContext* opCtx NamespaceString::kLogicalSessionsNamespace, includeBuildUUIDs, options); uassert(ErrorCodes::NamespaceNotFound, - str::stream() << NamespaceString::kLogicalSessionsNamespace << " does not exist", + str::stream() << NamespaceString::kLogicalSessionsNamespace.toStringForErrorMsg() + << " does not exist", indexes.size() != 0u); auto index = std::find_if(indexes.begin(), indexes.end(), [](const BSONObj& index) { @@ -162,12 +163,12 @@ void SessionsCollectionRS::checkSessionsCollectionExists(OperationContext* opCtx }); uassert(ErrorCodes::IndexNotFound, - str::stream() << NamespaceString::kLogicalSessionsNamespace + str::stream() << NamespaceString::kLogicalSessionsNamespace.toStringForErrorMsg() << " does not have the required TTL index", index != indexes.end()); uassert(ErrorCodes::IndexOptionsConflict, - str::stream() << NamespaceString::kLogicalSessionsNamespace + str::stream() << NamespaceString::kLogicalSessionsNamespace.toStringForErrorMsg() << " currently has the incorrect timeout for the TTL index", index->hasField("expireAfterSeconds") && index->getField("expireAfterSeconds").Int() == diff --git a/src/mongo/db/session/sessions_collection_standalone.cpp b/src/mongo/db/session/sessions_collection_standalone.cpp index ef63bd4b2e0..0f5a09c249d 100644 --- a/src/mongo/db/session/sessions_collection_standalone.cpp +++ b/src/mongo/db/session/sessions_collection_standalone.cpp @@ -60,9 +60,10 @@ void SessionsCollectionStandalone::setupSessionsCollection(OperationContext* opC BSONObj info; if (!client.runCommand(NamespaceString::kLogicalSessionsNamespace.dbName(), cmd, info)) { - uassertStatusOKWithContext(getStatusFromCommandResult(info), - str::stream() << "Failed to create " - << NamespaceString::kLogicalSessionsNamespace); + uassertStatusOKWithContext( + getStatusFromCommandResult(info), + str::stream() << "Failed to create " + << NamespaceString::kLogicalSessionsNamespace.toStringForErrorMsg()); } } } @@ -76,7 +77,8 @@ void SessionsCollectionStandalone::checkSessionsCollectionExists(OperationContex NamespaceString::kLogicalSessionsNamespace, includeBuildUUIDs, options); uassert(ErrorCodes::NamespaceNotFound, - str::stream() << NamespaceString::kLogicalSessionsNamespace << " does not exist", + str::stream() << NamespaceString::kLogicalSessionsNamespace.toStringForErrorMsg() + << " does not exist", indexes.size() != 0u); auto index = std::find_if(indexes.begin(), indexes.end(), [](const BSONObj& index) { @@ -84,12 +86,12 @@ void SessionsCollectionStandalone::checkSessionsCollectionExists(OperationContex }); uassert(ErrorCodes::IndexNotFound, - str::stream() << NamespaceString::kLogicalSessionsNamespace + str::stream() << NamespaceString::kLogicalSessionsNamespace.toStringForErrorMsg() << " does not have the required TTL index", index != indexes.end()); uassert(ErrorCodes::IndexOptionsConflict, - str::stream() << NamespaceString::kLogicalSessionsNamespace + str::stream() << NamespaceString::kLogicalSessionsNamespace.toStringForErrorMsg() << " currently has the incorrect timeout for the TTL index", index->hasField("expireAfterSeconds") && index->getField("expireAfterSeconds").Int() == |
