summaryrefslogtreecommitdiff
path: root/src/mongo/db/transaction
diff options
context:
space:
mode:
authorSophia Tan <sophia_tll@hotmail.com>2023-04-18 07:41:17 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-04-18 08:57:59 +0000
commit274cb477d2a1b64ac81b85e9f1b3172387ce0184 (patch)
treee89f778fa52a40413403b6a125b69271cf8469c0 /src/mongo/db/transaction
parent8863b04c282557081cf2634bce0e26f4fa5389b2 (diff)
downloadmongo-274cb477d2a1b64ac81b85e9f1b3172387ce0184.tar.gz
SERVER-74486 Always include tenant in collection name attributes in error messages
Diffstat (limited to 'src/mongo/db/transaction')
-rw-r--r--src/mongo/db/transaction/transaction_operations.cpp2
-rw-r--r--src/mongo/db/transaction/transaction_participant.cpp41
2 files changed, 24 insertions, 19 deletions
diff --git a/src/mongo/db/transaction/transaction_operations.cpp b/src/mongo/db/transaction/transaction_operations.cpp
index 9c6b8282fc4..817711794ec 100644
--- a/src/mongo/db/transaction/transaction_operations.cpp
+++ b/src/mongo/db/transaction/transaction_operations.cpp
@@ -317,7 +317,7 @@ std::size_t TransactionOperations::logOplogEntries(
if (imageToWrite) {
uassert(6054002,
- str::stream() << NamespaceString::kConfigImagesNamespace
+ str::stream() << NamespaceString::kConfigImagesNamespace.toStringForErrorMsg()
<< " can only store the pre or post image of one "
"findAndModify operation for each "
"transaction",
diff --git a/src/mongo/db/transaction/transaction_participant.cpp b/src/mongo/db/transaction/transaction_participant.cpp
index fa0611f70b8..19a77dba518 100644
--- a/src/mongo/db/transaction/transaction_participant.cpp
+++ b/src/mongo/db/transaction/transaction_participant.cpp
@@ -183,10 +183,10 @@ void rethrowPartialIndexQueryBadValueWithContext(const DBException& ex) {
ex.toStatus(),
str::stream()
<< "Failed to find partial index for "
- << NamespaceString::kSessionTransactionsTableNamespace.ns()
+ << NamespaceString::kSessionTransactionsTableNamespace.toStringForErrorMsg()
<< ". Please create an index directly on this replica set with the specification: "
<< MongoDSessionCatalog::getConfigTxnPartialIndexSpec() << " or drop the "
- << NamespaceString::kSessionTransactionsTableNamespace.ns()
+ << NamespaceString::kSessionTransactionsTableNamespace.toStringForErrorMsg()
<< " collection and step up a new primary.");
}
}
@@ -396,21 +396,23 @@ void updateSessionEntry(OperationContext* opCtx,
AutoGetCollection collection(
opCtx, NamespaceString::kSessionTransactionsTableNamespace, MODE_IX);
- uassert(40527,
- str::stream() << "Unable to persist transaction state because the session transaction "
- "collection is missing. This indicates that the "
- << NamespaceString::kSessionTransactionsTableNamespace.ns()
- << " collection has been manually deleted.",
- collection.getCollection());
+ uassert(
+ 40527,
+ str::stream() << "Unable to persist transaction state because the session transaction "
+ "collection is missing. This indicates that the "
+ << NamespaceString::kSessionTransactionsTableNamespace.toStringForErrorMsg()
+ << " collection has been manually deleted.",
+ collection.getCollection());
WriteUnitOfWork wuow(opCtx);
auto idIndex = collection->getIndexCatalog()->findIdIndex(opCtx);
- uassert(40672,
- str::stream() << "Failed to fetch _id index for "
- << NamespaceString::kSessionTransactionsTableNamespace.ns(),
- idIndex);
+ uassert(
+ 40672,
+ str::stream() << "Failed to fetch _id index for "
+ << NamespaceString::kSessionTransactionsTableNamespace.toStringForErrorMsg(),
+ idIndex);
auto indexAccess =
collection->getIndexCatalog()->getEntry(idIndex)->accessMethod()->asSortedData();
@@ -442,11 +444,13 @@ void updateSessionEntry(OperationContext* opCtx,
auto originalDoc = originalRecordData.toBson();
const auto parentLsidFieldName = SessionTxnRecord::kParentSessionIdFieldName;
- uassert(5875700,
- str::stream() << "Cannot modify the '" << parentLsidFieldName << "' field of "
- << NamespaceString::kSessionTransactionsTableNamespace << " entries",
- updateMod.getObjectField(parentLsidFieldName)
- .woCompare(originalDoc.getObjectField(parentLsidFieldName)) == 0);
+ uassert(
+ 5875700,
+ str::stream() << "Cannot modify the '" << parentLsidFieldName << "' field of "
+ << NamespaceString::kSessionTransactionsTableNamespace.toStringForErrorMsg()
+ << " entries",
+ updateMod.getObjectField(parentLsidFieldName)
+ .woCompare(originalDoc.getObjectField(parentLsidFieldName)) == 0);
invariant(collection->getDefaultCollator() == nullptr);
boost::intrusive_ptr<ExpressionContext> expCtx(
@@ -1653,7 +1657,7 @@ Timestamp TransactionParticipant::Participant::prepareTransaction(
uassert(ErrorCodes::OperationNotSupportedInTransaction,
str::stream() << "prepareTransaction failed because one of the transaction "
"operations was done against a temporary collection '"
- << collection->ns() << "'.",
+ << collection->ns().toStringForErrorMsg() << "'.",
!collection->isTemporary());
}
@@ -3147,6 +3151,7 @@ void TransactionParticipant::Participant::_refreshActiveTransactionParticipantsF
<< parentTxnParticipant._sessionId() << " to be "
<< *activeRetryableWriteTxnNumber << " found a "
<< NamespaceString::kSessionTransactionsTableNamespace
+ .toStringForErrorMsg()
<< " entry for an internal transaction for retryable writes with "
<< "transaction number " << *childLsid.getTxnNumber(),
*childLsid.getTxnNumber() == *activeRetryableWriteTxnNumber);