diff --git a/src/yb/client/snapshot-txn-test.cc b/src/yb/client/snapshot-txn-test.cc index 80c5ca01c338..e0b8e46de6da 100644 --- a/src/yb/client/snapshot-txn-test.cc +++ b/src/yb/client/snapshot-txn-test.cc @@ -589,6 +589,7 @@ bool IntermittentTxnFailure(const Status& status) { "Transaction expired"s, "Transaction metadata missing"s, "Unknown transaction, could be recently aborted"s, + "Transaction was recently aborted"s, }; auto msg = status.ToString(); for (const auto& allowed : kAllowedMessages) { @@ -685,10 +686,14 @@ void SnapshotTxnTest::TestMultiWriteWithRestart() { op = ReadRow(session, key->value); auto flush_result = session->Flush(); if (flush_result.ok()) { - break; + if (op->succeeded()) { + break; + } + if (op->response().error_message().find("timed out after") == std::string::npos) { + ASSERT_TRUE(op->succeeded()) << "Read failed: " << op->response().ShortDebugString(); + } } } - ASSERT_TRUE(op->succeeded()) << "Read failed: " << op->response().ShortDebugString(); auto rowblock = yb::ql::RowsResult(op.get()).GetRowBlock(); ASSERT_EQ(rowblock->row_count(), 1); const auto& first_column = rowblock->row(0).column(0); diff --git a/src/yb/client/transaction.cc b/src/yb/client/transaction.cc index 754ff1010c0c..999725af123c 100644 --- a/src/yb/client/transaction.cc +++ b/src/yb/client/transaction.cc @@ -712,10 +712,6 @@ class YBTransaction::Impl final { } VLOG_WITH_PREFIX(4) << "Commit done: " << actual_status; commit_callback_(actual_status); - - if (actual_status.IsExpired()) { - DoAbortCleanup(transaction); - } } void AbortDone(const Status& status, diff --git a/src/yb/integration-tests/cql-index-test.cc b/src/yb/integration-tests/cql-index-test.cc index 9c1c8a5953c6..7836c70b2217 100644 --- a/src/yb/integration-tests/cql-index-test.cc +++ b/src/yb/integration-tests/cql-index-test.cc @@ -190,7 +190,7 @@ TEST_F(CqlIndexTest, TxnCleanup) { CleanFutures(&futures, CheckReady::kFalse); - AssertNoRunningTransactions(cluster_.get()); + AssertRunningTransactionsCountLessOrEqualTo(cluster_.get(), 5); } } // namespace yb diff --git a/src/yb/integration-tests/mini_cluster_utils.cc b/src/yb/integration-tests/mini_cluster_utils.cc index bb1376f340dc..f89561fb06c9 100644 --- a/src/yb/integration-tests/mini_cluster_utils.cc +++ b/src/yb/integration-tests/mini_cluster_utils.cc @@ -37,7 +37,7 @@ size_t CountRunningTransactions(MiniCluster* cluster) { return result; } -void AssertNoRunningTransactions(MiniCluster* cluster) { +void AssertRunningTransactionsCountLessOrEqualTo(MiniCluster* cluster, size_t limit_per_tablet) { MonoTime deadline = MonoTime::Now() + 7s * kTimeMultiplier; bool has_bad = false; for (int i = 0; i != cluster->num_tablet_servers(); ++i) { @@ -67,8 +67,8 @@ void AssertNoRunningTransactions(MiniCluster* cluster) { for (const auto& peer : tablets) { auto participant = peer->tablet()->transaction_participant(); if (participant) { - auto status = Wait([participant] { - return participant->TEST_GetNumRunningTransactions() == 0; + auto status = Wait([participant, limit_per_tablet] { + return participant->TEST_GetNumRunningTransactions() <= limit_per_tablet; }, deadline, "Wait until no transactions are running"); @@ -85,4 +85,8 @@ void AssertNoRunningTransactions(MiniCluster* cluster) { ASSERT_FALSE(has_bad); } +void AssertNoRunningTransactions(MiniCluster* cluster) { + AssertRunningTransactionsCountLessOrEqualTo(cluster, 0); +} + } // namespace yb diff --git a/src/yb/integration-tests/mini_cluster_utils.h b/src/yb/integration-tests/mini_cluster_utils.h index ee97aa22bea4..b989e5f73b40 100644 --- a/src/yb/integration-tests/mini_cluster_utils.h +++ b/src/yb/integration-tests/mini_cluster_utils.h @@ -22,6 +22,7 @@ class MiniCluster; size_t CountRunningTransactions(MiniCluster* cluster); void AssertNoRunningTransactions(MiniCluster* cluster); +void AssertRunningTransactionsCountLessOrEqualTo(MiniCluster* cluster, size_t limit_per_tablet); } // namespace yb