Skip to content

Commit b0ad230

Browse files
craig[bot]yuzefovich
andcommitted
Merge #149504
149504: logictest: deflake partial_stats r=yuzefovich a=yuzefovich Whenever we collect a new statistic, in order to guarantee that it'll be observed by the optimizer on the following query, we must clear the stats cache after having collected that stat. This `Clear` call was missing after having collected the partial stat (which also results in generating the merged stat). It was incompletely fixed in 5707cf1 by adding a retry to the EXPLAIN and resulted in a rare case where the merged stat is not observed by a later query. (I'm not quite sure why `retry` on an earlier statement is insufficient to guarantee that the merged stat is observed by a later statement, given that no more new stats are created. I did see the flake go away with this patch.) This commit clears the stats cache addressing the flake. (Also it looks like this flake was exposed via cabf482.) Having a `retry` on the EXPLAIN query is an alternative way of fixing the flake. Some more context can be found at 5707cf1. Fixes: #149309. Release note: None Co-authored-by: Yahor Yuzefovich <[email protected]>
2 parents 9644793 + cb4946c commit b0ad230

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pkg/sql/opt/exec/execbuilder/testdata/partial_stats

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1390,7 +1390,12 @@ INSERT INTO ka VALUES (10, 10)
13901390
statement ok
13911391
CREATE STATISTICS ka_partialstat ON a FROM ka USING EXTREMES
13921392

1393-
query T retry
1393+
# Now clear the stats cache so that the query below is guaranteed to pick up the
1394+
# new stats (partial and merged).
1395+
statement ok
1396+
SELECT crdb_internal.clear_table_stats_cache();
1397+
1398+
query T
13941399
EXPLAIN SELECT * FROM ka WHERE a > 5
13951400
----
13961401
distribution: local

0 commit comments

Comments
 (0)