Skip to content

Commit

Permalink
[#20518] docdb: Adjust waits in GeoTransactionsPromotionConflictAbort…
Browse files Browse the repository at this point in the history
…Test.TestConflictAbortBeforeNewHeartbeat

Summary:
GeoTransactionsPromotionConflictAbortTest.TestConflictAbortBeforeNewHeartbeat attempts to simulate a race condition that happens before the first heartbeat of a transaction. On slower builds like TSAN (and to a lesser degree, mac), things often take long enough that we fail to set up the race condition before the first heartbeat at 1500ms (TSAN)/500ms (non-TSAN).

This build increases all waits and heartbeat interval by several times to reduce flakiness.
Jira: DB-9524

Test Plan: Jenkins, triggered to run TSAN 100x, fail rate goes from ~70% to ~5% (remaining fails are a different issue where test isn't getting cleaned up).

Reviewers: sergei, bogdan

Reviewed By: bogdan

Subscribers: ybase, yql

Differential Revision: https://phorge.dev.yugabyte.com/D31867
  • Loading branch information
es1024 committed Feb 8, 2024
1 parent ca30501 commit 0214819
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/yb/yql/pgwrapper/geo_transactions_promotion-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -622,14 +622,17 @@ TEST_F_EX(GeoTransactionsPromotionTest,
}

TEST_F(GeoTransactionsPromotionConflictAbortTest, TestConflictAbortBeforeNewHeartbeat) {
ANNOTATE_UNPROTECTED_WRITE(FLAGS_transaction_heartbeat_usec) =
3000000 * yb::kTimeMultiplier;

auto conn0 = ASSERT_RESULT(Connect());
ASSERT_OK(conn0.ExecuteFormat(
"CREATE UNIQUE INDEX $0$1_1_key ON $0$1_1(value) TABLESPACE tablespace$1",
kTablePrefix, kLocalRegion));

ANNOTATE_UNPROTECTED_WRITE(FLAGS_force_global_transactions) = false;
ANNOTATE_UNPROTECTED_WRITE(FLAGS_TEST_new_txn_status_initial_heartbeat_delay_ms) =
400 * kTimeMultiplier;
2000 * kTimeMultiplier;

auto conn1 = ASSERT_RESULT(Connect());
auto conn2 = ASSERT_RESULT(Connect());
Expand All @@ -653,7 +656,7 @@ TEST_F(GeoTransactionsPromotionConflictAbortTest, TestConflictAbortBeforeNewHear

thread_holder.AddThreadFunctor([&conn2] {
// Give time for promotion to start, but not for initial heartbeat to be sent.
std::this_thread::sleep_for(200ms * kTimeMultiplier);
std::this_thread::sleep_for(1000ms * kTimeMultiplier);

ANNOTATE_UNPROTECTED_WRITE(FLAGS_TEST_override_transaction_priority) = 200;
ASSERT_OK(conn2.StartTransaction(IsolationLevel::SERIALIZABLE_ISOLATION));
Expand All @@ -662,7 +665,7 @@ TEST_F(GeoTransactionsPromotionConflictAbortTest, TestConflictAbortBeforeNewHear
"INSERT INTO $0$1_1(value, other_value) VALUES (1, 2)", kTablePrefix, kLocalRegion));
ASSERT_OK(conn2.CommitTransaction());
});
thread_holder.WaitAndStop(1000ms * kTimeMultiplier);
thread_holder.WaitAndStop(4000ms * kTimeMultiplier);
}

TEST_F(GeoTransactionsPromotionRF1Test,
Expand Down

0 comments on commit 0214819

Please sign in to comment.