Skip to content

Commit 615ae5b

Browse files
committed
[#25393] xCluster: Fix XClusterYsqlTest.DropTableOnProducerOnly in ASAN
Summary: The sleep timeout is calculated on global static initialization time which gets the default value of `cdc_parent_tablet_deletion_task_retry_secs` which is 30. The test cases set this flag to a lower number but do so much later during test execution. This change replaces the global static with a function that will compute the duration on the fly. Also fixing ASAN issues with `XClusterYSqlTestConsistentTransactionsTest` due to low timeouts Fixes #25393 Jira: DB-14622 Test Plan: XClusterYsqlTest.DropTableOnProducerOnly XClusterYSqlTestConsistentTransactionsTest Reviewers: jhe, sergei, xCluster Reviewed By: jhe Subscribers: ybase Differential Revision: https://phorge.dev.yugabyte.com/D40836
1 parent a45b1e1 commit 615ae5b

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/yb/integration-tests/xcluster/xcluster_test_base.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ namespace yb {
4949
using client::YBClient;
5050
using YBTables = std::vector<std::shared_ptr<client::YBTable>>;
5151

52-
constexpr int kRpcTimeout = NonTsanVsTsan(60, 120);
52+
constexpr int kRpcTimeout = RegularBuildVsSanitizers(60, 120);
5353
static const std::string kUniverseId = "test_universe";
5454
static const xcluster::ReplicationGroupId kReplicationGroupId("test_replication_group");
5555
static const std::string kKeyColumnName = "key";

src/yb/integration-tests/xcluster/xcluster_ysql-test.cc

+11-10
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,6 @@ using pgwrapper::PGConn;
125125
using pgwrapper::PGResultPtr;
126126
using pgwrapper::ToString;
127127

128-
const auto kMaxAsyncTaskWait =
129-
3s * FLAGS_cdc_parent_tablet_deletion_task_retry_secs * kTimeMultiplier;
130-
131128
static const client::YBTableName producer_transaction_table_name(
132129
YQL_DATABASE_CQL, master::kSystemNamespaceName, kGlobalTransactionsTableName);
133130

@@ -163,6 +160,10 @@ class XClusterYsqlTest : public XClusterYsqlTestBase {
163160
void TestDropTableOnConsumerThenProducer(bool restart_master);
164161
void TestDropTableOnProducerThenConsumer(bool restart_master);
165162

163+
MonoDelta MaxAsyncTaskWaitDuration() {
164+
return 3s * FLAGS_cdc_parent_tablet_deletion_task_retry_secs * kTimeMultiplier;
165+
}
166+
166167
private:
167168
};
168169

@@ -261,8 +262,8 @@ class XClusterYSqlTestConsistentTransactionsTest : public XClusterYsqlTest {
261262
auto now = CoarseMonoClock::Now();
262263
while (CoarseMonoClock::Now() < now + duration) {
263264
ASSERT_OK(producer_conn.ExecuteFormat(
264-
"insert into $0 values(generate_series($1, $2))", GetCompleteTableName(producer_table),
265-
key, key + transaction_size - 1));
265+
"BEGIN; insert into $0 values(generate_series($1, $2)); COMMIT;",
266+
GetCompleteTableName(producer_table), key, key + transaction_size - 1));
266267
key += transaction_size;
267268
}
268269
// Assert at least 100 transactions were written.
@@ -2993,7 +2994,7 @@ void XClusterYsqlTest::TestDropTableOnProducerThenConsumer(bool restart_master)
29932994
}
29942995

29952996
// Table should exist even after async tasks have run.
2996-
SleepFor(kMaxAsyncTaskWait);
2997+
SleepFor(MaxAsyncTaskWaitDuration());
29972998

29982999
auto producer_master = ASSERT_RESULT(producer_cluster()->GetLeaderMiniMaster());
29993000

@@ -3014,7 +3015,7 @@ void XClusterYsqlTest::TestDropTableOnProducerThenConsumer(bool restart_master)
30143015

30153016
ASSERT_OK(LoggedWaitFor(
30163017
[&producer_table_info]() { return producer_table_info->LockForRead()->started_deleting(); },
3017-
kMaxAsyncTaskWait, "Waiting for table to get delete"));
3018+
MaxAsyncTaskWaitDuration(), "Waiting for table to get delete"));
30183019
}
30193020

30203021
// Drop table on producer should hide the table until the consumer table is also dropped.
@@ -3084,7 +3085,7 @@ TEST_F(XClusterYsqlTest, DropTableOnProducerOnly) {
30843085
ASSERT_OK(DropYsqlTable(producer_cluster_, *producer_table_));
30853086

30863087
// Table should exist even after async tasks have run.
3087-
SleepFor(kMaxAsyncTaskWait);
3088+
SleepFor(MaxAsyncTaskWaitDuration());
30883089

30893090
auto producer_master = ASSERT_RESULT(producer_cluster()->GetLeaderMiniMaster());
30903091

@@ -3095,15 +3096,15 @@ TEST_F(XClusterYsqlTest, DropTableOnProducerOnly) {
30953096
// Table should remain hidden.
30963097
ASSERT_NOK(LoggedWaitFor(
30973098
[&producer_table_info]() { return producer_table_info->LockForRead()->started_deleting(); },
3098-
kMaxAsyncTaskWait, "Waiting for table to get delete"));
3099+
MaxAsyncTaskWaitDuration(), "Waiting for table to get delete"));
30993100
ASSERT_TRUE(producer_table_info->IsHiddenButNotDeleting());
31003101

31013102
// Reduce retention and make sure table drops.
31023103
ANNOTATE_UNPROTECTED_WRITE(FLAGS_cdc_wal_retention_time_secs) = 1;
31033104

31043105
ASSERT_OK(LoggedWaitFor(
31053106
[&producer_table_info]() { return producer_table_info->LockForRead()->started_deleting(); },
3106-
kMaxAsyncTaskWait, "Waiting for table to get delete"));
3107+
MaxAsyncTaskWaitDuration(), "Waiting for table to get delete"));
31073108

31083109
// Make sure stream is deleted from producer.
31093110
ASSERT_NOK(GetCDCStreamID(producer_table_->id()));

0 commit comments

Comments
 (0)