Skip to content

Commit a081a00

Browse files
sql: fix flaky TestIndexSplitAndScatterWithStats (#170661)
sql: fix flaky TestIndexSplitAndScatterWithStats
2 parents 4c4b655 + 5f1e802 commit a081a00

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

pkg/sql/index_split_scatter_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/cockroachdb/cockroach/pkg/config"
1616
"github.com/cockroachdb/cockroach/pkg/keys"
1717
"github.com/cockroachdb/cockroach/pkg/sql"
18+
"github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb"
1819
"github.com/cockroachdb/cockroach/pkg/testutils"
1920
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
2021
"github.com/cockroachdb/cockroach/pkg/testutils/skip"
@@ -165,6 +166,12 @@ func TestIndexSplitAndScatterWithStats(t *testing.T) {
165166
// Generate statistics for these tables.
166167
if statsExist {
167168
runner.Exec(t, "CREATE STATISTICS st FROM multi_column_split")
169+
// Force a stats cache refresh on all nodes so
170+
// MaybeSplitIndexSpans sees the new stats.
171+
tableID := descpb.ID(sqlutils.QueryTableID(t, cluster.ServerConn(0), "defaultdb", "public", "multi_column_split"))
172+
for i := 0; i < numNodes; i++ {
173+
cluster.Server(i).ExecutorConfig().(sql.ExecutorConfig).TableStatsCache.InvalidateTableStats(ctx, tableID)
174+
}
168175
}
169176
// Next create indexes on both tables.
170177
splitHookEnabled.Store(true)

0 commit comments

Comments
 (0)