Skip to content

Commit

Permalink
[#23975] YSQL, ASH: Fix TestYbAsh#testPgAuxInfo
Browse files Browse the repository at this point in the history
Summary:
Earlier, this test used to run a bunch of queries with
high sampling rate to make sure that the circular buffer
would wrap around. This started failing after tests in
tsan were enabled. Now the size of the circular buffer
is reduced to 1 KiB from the default of 16 KiB for the
test and the sampling interval is updated to 50 ms.
Jira: DB-12876

Test Plan:
Jenkins: test regex: testPgAuxInfo

The test passed 240/240 times with tsan on dev server

Reviewers: jason

Reviewed By: jason

Differential Revision: https://phorge.dev.yugabyte.com/D38122
  • Loading branch information
abhinab-yb committed Sep 19, 2024
1 parent 2478a50 commit aa14f76
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions java/yb-pgsql/src/test/java/org/yb/pgsql/TestYbAsh.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,11 @@
@RunWith(value = YBTestRunner.class)
public class TestYbAsh extends BasePgSQLTest {
private static final int ASH_SAMPLING_INTERVAL = 1000;

private static final int ASH_SAMPLE_SIZE = 500;

private static final String ASH_VIEW = "yb_active_session_history";

private void setAshConfigAndRestartCluster(
int sampling_interval, int sample_size) throws Exception {
int sampling_interval, int sample_size, int circular_buffer_size) throws Exception {
Map<String, String> flagMap = super.getTServerFlags();
if (isTestRunningWithConnectionManager()) {
flagMap.put("allowed_preview_flags_csv",
Expand All @@ -55,11 +53,18 @@ private void setAshConfigAndRestartCluster(
flagMap.put("ysql_yb_enable_ash", "true");
flagMap.put("ysql_yb_ash_sampling_interval_ms", String.valueOf(sampling_interval));
flagMap.put("ysql_yb_ash_sample_size", String.valueOf(sample_size));
// flagMap.put("create_initial_sys_catalog_snapshot", "true");
if (circular_buffer_size > 0) {
flagMap.put("ysql_yb_ash_circular_buffer_size", String.valueOf(circular_buffer_size));
}
Map<String, String> masterFlagMap = super.getMasterFlags();
restartClusterWithFlags(masterFlagMap, flagMap);
}

private void setAshConfigAndRestartCluster(
int sampling_interval, int sample_size) throws Exception {
setAshConfigAndRestartCluster(sampling_interval, sample_size, 0);
}

private void executePgSleep(Statement statement, long seconds) throws Exception {
statement.execute("SELECT pg_sleep(" + seconds + ")");
}
Expand Down Expand Up @@ -252,10 +257,10 @@ public void testNestedQueriesWithAsh() throws Exception {
*/
@Test
public void testPgAuxInfo() throws Exception {
setAshConfigAndRestartCluster(10, ASH_SAMPLE_SIZE);
setAshConfigAndRestartCluster(50, ASH_SAMPLE_SIZE, 1);
try (Statement statement = connection.createStatement()) {
statement.execute("CREATE TABLE test_table(k INT, v TEXT)");
for (int i = 0; i < 10000; ++i) {
for (int i = 0; i < 100; ++i) {
statement.execute(String.format("INSERT INTO test_table VALUES(%d, 'v-%d')", i, i));
statement.execute(String.format("SELECT v FROM test_table WHERE k=%d", i));
}
Expand Down

0 comments on commit aa14f76

Please sign in to comment.