Skip to content

Commit

Permalink
roachtest: import-cancellation: use a fixed seed; smaller import
Browse files Browse the repository at this point in the history
Currently, due to the randomness present in the test, there may be
significant variance in test runs. In some situations, the nature of the
random import cancellations may result in the test timing out. This
makes the test flaky.

Use a fixed seed for the test's PRNG to make the test more
deterministic.

Reduce the size of the overall import by lowering the
number of files used to generate the `lineitem` table. This should also
help stabilize the runtime.

Force the collection of table statistics as soon as the table has
finished importing.

Reduce the number of time each TPC-H query is repeated, from three to
two.

Fix #90510.

Release note: None.
  • Loading branch information
nicktrav committed Oct 22, 2022
1 parent fc8c372 commit 70b18d8
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions pkg/cmd/roachtest/tests/import_cancellation.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ func runImportCancellation(ctx context.Context, t test.Test, c cluster.Cluster)
t.Fatal(err)
}

rng, seed := randutil.NewPseudoRand()
seed := int64(1666467482296309000)
rng := randutil.NewTestRandWithSeed(seed)

tablesToNumFiles := map[string]int{
"region": 1,
Expand All @@ -93,7 +94,7 @@ func runImportCancellation(ctx context.Context, t test.Test, c cluster.Cluster)
"partsupp": 8,
"customer": 8,
"orders": 8,
"lineitem": 8,
"lineitem": 2,
}
for tbl := range tablesToNumFiles {
fixtureURL := fmt.Sprintf("gs://cockroach-fixtures/tpch-csv/schema/%s.sql?AUTH=implicit", tbl)
Expand Down Expand Up @@ -157,8 +158,8 @@ func runImportCancellation(ctx context.Context, t test.Test, c cluster.Cluster)
m.Go(func(ctx context.Context) error {
t.WorkerStatus(`running tpch workload`)
// maxOps flag will allow us to exit the workload once all the queries
// were run 3 times.
const numRunsPerQuery = 3
// were run 2 times.
const numRunsPerQuery = 2
const maxLatency = 500 * time.Second
maxOps := numRunsPerQuery * numQueries
cmd := fmt.Sprintf(
Expand Down Expand Up @@ -299,6 +300,16 @@ func (t *importCancellationTest) runImportSequence(
t.Fatalf("Expected zero remaining %q files after final attempt, but %d remaining.",
tableName, len(filesToImport))
}

// Kick off a stats collection job for the table. This serves a dual purpose.
// Up-to-date statistics on the table helps the optimizer during the query
// phase of the test. The stats job also requires scanning a large swath of
// the keyspace, which results in greater test coverage.
stmt := fmt.Sprintf(`CREATE STATISTICS %s_stats FROM csv.%s`, tableName, tableName)
_, err := conn.ExecContext(ctx, stmt)
if err != nil {
t.Fatal(err)
}
}

// remove removes all elements from a that exist in b.
Expand Down

0 comments on commit 70b18d8

Please sign in to comment.