Skip to content

Commit 859ed95

Browse files
committed
SERVER-34583 Clean up transaction error codes.
1 parent 6dd1af8 commit 859ed95

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/mongo/base/error_codes.err

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ error_code("DNSRecordTypeMismatch", 240)
241241
error_code("ConversionFailure", 241)
242242
error_code("CannotCreateCollection", 242)
243243
error_code("IncompatibleWithUpgradedServer", 243)
244-
error_code("TransactionAborted", 244)
244+
error_code("NOT_YET_AVAILABLE_TransactionAborted", 244)
245245
error_code("BrokenPromise", 245)
246246
error_code("SnapshotUnavailable", 246)
247247
error_code("ProducerConsumerQueueBatchTooLarge", 247)

src/mongo/db/session.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ void Session::_commitTransaction(stdx::unique_lock<stdx::mutex> lk, OperationCon
959959
lk.lock();
960960
// It's possible some other thread aborted the transaction (e.g. through killSession) while
961961
// the opObserver was running. If that happened, the commit should be reported as failed.
962-
uassert(ErrorCodes::TransactionAborted,
962+
uassert(ErrorCodes::NoSuchTransaction,
963963
str::stream() << "Transaction " << opCtx->getTxnNumber()
964964
<< " aborted while attempting to commit",
965965
_txnState == MultiDocumentTransactionState::kInProgress &&
@@ -1044,7 +1044,7 @@ void Session::_checkIsActiveTransaction(WithLock, TxnNumber txnNumber, bool chec
10441044
<< " is now active.",
10451045
txnNumber == _activeTxnNumber);
10461046

1047-
uassert(ErrorCodes::TransactionAborted,
1047+
uassert(ErrorCodes::NoSuchTransaction,
10481048
str::stream() << "Transaction " << txnNumber << " has been aborted.",
10491049
!checkAbort || _txnState != MultiDocumentTransactionState::kAborted);
10501050
}

src/mongo/db/session_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ TEST_F(SessionTest, ConcurrencyOfAddTransactionOperationAndAbort) {
10581058
auto operation = repl::OplogEntry::makeInsertOperation(kNss, kUUID, BSON("TestValue" << 0));
10591059
ASSERT_THROWS_CODE(session.addTransactionOperation(opCtx(), operation),
10601060
AssertionException,
1061-
ErrorCodes::TransactionAborted);
1061+
ErrorCodes::NoSuchTransaction);
10621062
}
10631063

10641064
TEST_F(SessionTest, ConcurrencyOfAddTransactionOperationAndMigration) {
@@ -1108,7 +1108,7 @@ TEST_F(SessionTest, ConcurrencyOfEndTransactionAndRetrieveOperationsAndAbort) {
11081108
// An endTransactionAndRetrieveOperations() after an abort should uassert.
11091109
ASSERT_THROWS_CODE(session.endTransactionAndRetrieveOperations(opCtx()),
11101110
AssertionException,
1111-
ErrorCodes::TransactionAborted);
1111+
ErrorCodes::NoSuchTransaction);
11121112
}
11131113

11141114
TEST_F(SessionTest, ConcurrencyOfEndTransactionAndRetrieveOperationsAndMigration) {
@@ -1157,7 +1157,7 @@ TEST_F(SessionTest, ConcurrencyOfCommitTransactionAndAbort) {
11571157

11581158
// An commitTransaction() after an abort should uassert.
11591159
ASSERT_THROWS_CODE(
1160-
session.commitTransaction(opCtx()), AssertionException, ErrorCodes::TransactionAborted);
1160+
session.commitTransaction(opCtx()), AssertionException, ErrorCodes::NoSuchTransaction);
11611161
}
11621162

11631163
TEST_F(SessionTest, ConcurrencyOfCommitTransactionAndMigration) {

0 commit comments

Comments
 (0)