diff options
author | Jonathan Lee <jonathan.lee@mongodb.com> | 2021-09-30 17:04:04 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-09-30 18:04:41 +0000 |
commit | c8b6f1a2c01db4b47a7615651a76589f9cff6fa7 (patch) | |
tree | c5792668d3c70cf982080d0bb5c598b252cbf38f | |
parent | 2a64c487504e837985ce6fda6ee6060275cb2cf8 (diff) | |
download | mongo-c8b6f1a2c01db4b47a7615651a76589f9cff6fa7.tar.gz |
SERVER-59702 Add TxnRetryCounterTooOld to the list of VoteAbort errors
-rw-r--r-- | src/mongo/base/error_codes.yml | 2 | ||||
-rw-r--r-- | src/mongo/db/s/transaction_coordinator_test.cpp | 31 |
2 files changed, 31 insertions, 2 deletions
diff --git a/src/mongo/base/error_codes.yml b/src/mongo/base/error_codes.yml index c4b8e927f9d..420b78dc8ff 100644 --- a/src/mongo/base/error_codes.yml +++ b/src/mongo/base/error_codes.yml @@ -451,7 +451,7 @@ error_codes: - {code: 355, name: InterruptedDueToStorageChange,categories: [Interruption,CancellationError]} - - {code: 356, name: TxnRetryCounterTooOld, extra: TxnRetryCounterTooOldInfo} + - {code: 356, name: TxnRetryCounterTooOld, extra: TxnRetryCounterTooOldInfo, categories: [VoteAbortError]} - {code: 357, name: InvalidBSONType} diff --git a/src/mongo/db/s/transaction_coordinator_test.cpp b/src/mongo/db/s/transaction_coordinator_test.cpp index 924b9920b37..602165fceb2 100644 --- a/src/mongo/db/s/transaction_coordinator_test.cpp +++ b/src/mongo/db/s/transaction_coordinator_test.cpp @@ -66,6 +66,10 @@ StatusWith<BSONObj> makePrepareOkResponse(const Timestamp& timestamp) { const StatusWith<BSONObj> kPrepareOk = makePrepareOkResponse(kDummyPrepareTimestamp); const StatusWith<BSONObj> kPrepareOkNoTimestamp = BSON("ok" << 1); +const StatusWith<BSONObj> kTxnRetryCounterTooOld = + BSON("ok" << 0 << "code" << ErrorCodes::TxnRetryCounterTooOld << "errmsg" + << "txnRetryCounter is too old" + << "txnRetryCounter" << 1); /** * Searches for a client matching the name and mark the operation context as killed. @@ -866,7 +870,8 @@ TEST_F(TransactionCoordinatorTest, RunCommitProducesAbortDecisionOnAbortAndCommi coordinator.onCompletion().get(), AssertionException, ErrorCodes::NoSuchTransaction); } -TEST_F(TransactionCoordinatorTest, RunCommitProducesAbortDecisionOnCommitAndAbortResponses) { +TEST_F(TransactionCoordinatorTest, + RunCommitProducesAbortDecisionOnCommitAndAbortResponsesNoSuchTransaction) { TransactionCoordinator coordinator( operationContext(), _lsid, @@ -888,6 +893,30 @@ TEST_F(TransactionCoordinatorTest, RunCommitProducesAbortDecisionOnCommitAndAbor coordinator.onCompletion().get(), AssertionException, ErrorCodes::NoSuchTransaction); } +TEST_F(TransactionCoordinatorTest, + RunCommitProducesAbortDecisionOnCommitAndAbortResponsesTxnRetryCounterTooOld) { + TransactionCoordinator coordinator( + operationContext(), + _lsid, + _txnNumber, + std::make_unique<txn::AsyncWorkScheduler>(getServiceContext()), + Date_t::max()); + coordinator.runCommit(operationContext(), kTwoShardIdList); + auto commitDecisionFuture = coordinator.getDecision(); + + onCommands( + {[&](const executor::RemoteCommandRequest& request) { return kPrepareOk; }, + [&](const executor::RemoteCommandRequest& request) { return kTxnRetryCounterTooOld; }}); + + assertAbortSentAndRespondWithSuccess(); + assertAbortSentAndRespondWithSuccess(); + + ASSERT_THROWS_CODE( + commitDecisionFuture.get(), AssertionException, ErrorCodes::TxnRetryCounterTooOld); + ASSERT_THROWS_CODE( + coordinator.onCompletion().get(), AssertionException, ErrorCodes::TxnRetryCounterTooOld); +} + TEST_F(TransactionCoordinatorTest, RunCommitProducesAbortDecisionOnSingleAbortResponseOnly) { TransactionCoordinator coordinator( operationContext(), |