Skip to content

Commit

Permalink
[#10855] YSQL: fix flakiness of test yb_pg_partition_aggregate
Browse files Browse the repository at this point in the history
Summary:
The test fails with the following error:
```
*** /tmp/yb_tests__2021-12-12T14_29_06__17676.17249.17116/pgregress_output/expected/yb_pg_partition_aggregate.out   2021-12-12 14:47:10.730866113 +0000
--- /tmp/yb_tests__2021-12-12T14_29_06__17676.17249.17116/pgregress_output/results/yb_pg_partition_aggregate.out    2021-12-12 14:47:10.603854965 +0000
***************
*** 710,715 ****
--- 710,716 ----
  ALTER TABLE pagg_tab_ml ATTACH PARTITION pagg_tab_ml_p3 FOR VALUES FROM (20) TO (30);
  INSERT INTO pagg_tab_ml SELECT i % 30, i % 10, to_char(i % 4, 'FM0000') FROM generate_series(0, 29999) i;
  ANALYZE pagg_tab_ml;
+ ERROR:  Operation failed. Try again: Transaction aborted: b69768c7-0be1-435b-aa86-ce3989f27948
  -- For Parallel Append
  SET max_parallel_workers_per_gather TO 2;
  -- Full aggregation at level 1 as GROUP BY clause matches with PARTITION KEY
```

This is because of the large number of rows (30,000) in the pagg_tab_ml.
This also happens for the table pagg_tab_para which also contains 30,000 rows.

GHI [[ #10989 | #10989 ]] tracks why the large number of rows leads to transaction abort,
but as part of this fix, the number for rows for this table is reduced. Further
flakiness is because the test times out at 1800 seconds (irrespective of the value of
getTestMethodTimeout()), which is the timeout for
process_tree_supervisor set in common-test-env.sh.

Since the Partitions test is now extremely long-running, this patch breaks up the
partitions schedule into smaller and more manageable schedules.

Running multiple schedules from the same PgRegressTest was causing a
conflict while creating the pg_regress output dir. Hence, this patch creates
a new subdirectory for the outputdir using the schedule's name.

Test Plan: ybd --scb --sj --java-test org.yb.pgsql.TestPgRegressPartitions'

Reviewers: alex

Reviewed By: alex

Subscribers: kannan, yql

Differential Revision: https://phabricator.dev.yugabyte.com/D14613
  • Loading branch information
deeps1991 committed Jan 19, 2022
1 parent 282ecae commit ccabdf7
Show file tree
Hide file tree
Showing 10 changed files with 180 additions and 143 deletions.
5 changes: 2 additions & 3 deletions java/yb-pgsql/src/test/java/org/yb/pgsql/BasePgSQLTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,9 @@ public class BasePgSQLTest extends BaseMiniClusterTest {
public void runPgRegressTest(File inputDir, String schedule, long maxRuntimeMillis)
throws Exception {
final int tserverIndex = 0;
String label = String.format("using schedule %s at %s", schedule, inputDir);
PgRegressRunner pgRegress = new PgRegressRunner(inputDir, label, maxRuntimeMillis);
PgRegressRunner pgRegress = new PgRegressRunner(inputDir, schedule, maxRuntimeMillis);
ProcessBuilder procBuilder = new PgRegressBuilder()
.setDirs(inputDir, PgRegressRunner.OUTPUT_DIR)
.setDirs(inputDir, pgRegress.outputDir())
.setSchedule(schedule)
.setHost(getPgHost(tserverIndex))
.setPort(getPgPort(tserverIndex))
Expand Down
20 changes: 13 additions & 7 deletions java/yb-pgsql/src/test/java/org/yb/pgsql/PgRegressRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
public class PgRegressRunner {

private static final Logger LOG = LoggerFactory.getLogger(PgRegressRunner.class);
public static final File OUTPUT_DIR = new File(TestUtils.getBaseTmpDir(), "pgregress_output");

private File pgRegressInputDir;
private File pgRegressOutputDir;
private Process pgRegressProc;
private LogPrinter stdoutLogPrinter, stderrLogPrinter;
private String label;
Expand All @@ -54,13 +54,15 @@ public class PgRegressRunner {
private long maxRuntimeMillis;
private long startTimeMillis;

public PgRegressRunner(File pgRegressInputDir, String label, long maxRuntimeMillis) {
public PgRegressRunner(File pgRegressInputDir, String schedule, long maxRuntimeMillis) {
this.pgRegressInputDir = pgRegressInputDir;

this.label = label;
this.label = String.format("using schedule %s at %s", schedule, pgRegressInputDir);
this.maxRuntimeMillis = maxRuntimeMillis;

regressionDiffsPath = new File(OUTPUT_DIR, "regression.diffs");
File testDir = new File(TestUtils.getBaseTmpDir(), "pgregress_output");
pgRegressOutputDir = new File(testDir, schedule);
regressionDiffsPath = new File(pgRegressOutputDir, "regression.diffs");
}

private Pattern FAILED_TEST_LINE_RE =
Expand All @@ -79,6 +81,10 @@ public void handleLine(String line) {
};
}

public File outputDir() {
return pgRegressOutputDir;
}

public void start(ProcessBuilder procBuilder)
throws IOException, NoSuchFieldException, IllegalAccessException {
if (regressionDiffsPath.exists()) {
Expand Down Expand Up @@ -123,8 +129,8 @@ public void stop() throws InterruptedException, IOException {
if (!sortedFailedTests.isEmpty()) {
LOG.info("Failed tests: " + sortedFailedTests);
for (String testName : sortedFailedTests) {
File expectedFile = new File(new File(OUTPUT_DIR, "expected"), testName + ".out");
File resultFile = new File(new File(OUTPUT_DIR, "results"), testName + ".out");
File expectedFile = new File(new File(pgRegressOutputDir, "expected"), testName + ".out");
File resultFile = new File(new File(pgRegressOutputDir, "results"), testName + ".out");
if (!expectedFile.exists()) {
LOG.warn("Expected test output file " + expectedFile + " not found.");
continue;
Expand All @@ -139,7 +145,7 @@ public void stop() throws InterruptedException, IOException {
}

if (!ConfForTesting.isCI()) {
final Path pgRegressOutputPath = Paths.get(OUTPUT_DIR.toString());
final Path pgRegressOutputPath = Paths.get(pgRegressOutputDir.toString());

LOG.info("Copying test result files and generated SQL and expected output " +
pgRegressOutputPath + " back to " + pgRegressInputDir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,26 @@
public class TestPgRegressPartitions extends BasePgSQLTest {
@Override
public int getTestMethodTimeoutSec() {
return 3000;
return getPerfMaxRuntime(500, 700, 900, 900, 900);
}

@Test
public void testPgRegressPartitions() throws Exception {
runPgRegressTest("yb_pg_partitions_schedule");
public void misc() throws Exception {
runPgRegressTest("yb_pg_partitions_misc_schedule");
}

@Test
public void partitionwiseJoin() throws Exception {
runPgRegressTest("yb_pg_partition_join_schedule");
}

@Test
public void pruning() throws Exception {
runPgRegressTest("yb_pg_partition_prune_schedule");
}

@Test
public void yb_partitions_tests() throws Exception {
runPgRegressTest("yb_partitions_schedule");
}
}
Loading

0 comments on commit ccabdf7

Please sign in to comment.