Skip to content

Commit 8ed0592

Browse files
committed
logictest: fix probable flake around using old stats cache entry
We just saw a failure in a logic test that verifies the number of parallel lookup joins based on the recently added heuristic. I couldn't immediately reproduce it, but I think what happened was that we used a stale stats cache entry which didn't pick up the newly-collected table stats. In this test we need precise control of which stats are used, so this commit clears the stats cache before each query where we need it. Release note: None
1 parent 6e82d05 commit 8ed0592

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

pkg/ccl/logictestccl/testdata/logic_test/regional_by_row_cascade

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ INSERT INTO child (c, p, crdb_region) VALUES (1000, 100, 'us-east-1'), (2000, 20
5858
statement ok
5959
ANALYZE great_grandparent;
6060

61+
# Clear the stat cache so that the new statistic is guaranteed to be used.
62+
statement ok
63+
SELECT crdb_internal.clear_table_stats_cache();
64+
6165
# Only the scan in the main query is parallelized when we don't have stats on
6266
# the descendant tables.
6367
query I
@@ -68,6 +72,10 @@ SELECT count(*) FROM [EXPLAIN (VERBOSE) DELETE FROM great_grandparent WHERE i =
6872
statement ok
6973
ANALYZE grandparent;
7074

75+
# Clear the stat cache so that the new statistic is guaranteed to be used.
76+
statement ok
77+
SELECT crdb_internal.clear_table_stats_cache();
78+
7179
# Now we also should parallelize lookup join into the grandparent table.
7280
query I
7381
SELECT count(*) FROM [EXPLAIN (VERBOSE) DELETE FROM great_grandparent WHERE i = 1] WHERE info LIKE '%parallel%';
@@ -77,6 +85,10 @@ SELECT count(*) FROM [EXPLAIN (VERBOSE) DELETE FROM great_grandparent WHERE i =
7785
statement ok
7886
ANALYZE parent;
7987

88+
# Clear the stat cache so that the new statistic is guaranteed to be used.
89+
statement ok
90+
SELECT crdb_internal.clear_table_stats_cache();
91+
8092
# Now we also should parallelize lookup join into the parent table.
8193
query I
8294
SELECT count(*) FROM [EXPLAIN (VERBOSE) DELETE FROM great_grandparent WHERE i = 1] WHERE info LIKE '%parallel%';
@@ -86,6 +98,10 @@ SELECT count(*) FROM [EXPLAIN (VERBOSE) DELETE FROM great_grandparent WHERE i =
8698
statement ok
8799
ANALYZE child;
88100

101+
# Clear the stat cache so that the new statistic is guaranteed to be used.
102+
statement ok
103+
SELECT crdb_internal.clear_table_stats_cache();
104+
89105
# Finally, all three lookup joins as well as the scan in the main query should
90106
# be parallelized.
91107
query T
@@ -288,6 +304,10 @@ ALTER TABLE grandparent INJECT STATISTICS '[
288304
}
289305
]'
290306

307+
# Clear the stat cache so that the new statistic is guaranteed to be used.
308+
statement ok
309+
SELECT crdb_internal.clear_table_stats_cache();
310+
291311
query I
292312
SELECT count(*) FROM [EXPLAIN (VERBOSE) DELETE FROM great_grandparent WHERE i = 1] WHERE info LIKE '%parallel%';
293313
----
@@ -329,6 +349,10 @@ ALTER TABLE grandparent INJECT STATISTICS '[
329349
}
330350
]'
331351

352+
# Clear the stat cache so that the new statistic is guaranteed to be used.
353+
statement ok
354+
SELECT crdb_internal.clear_table_stats_cache();
355+
332356
query I
333357
SELECT count(*) FROM [EXPLAIN (VERBOSE) DELETE FROM great_grandparent WHERE i = 1] WHERE info LIKE '%parallel%';
334358
----

0 commit comments

Comments
 (0)