Skip to content

sql: fix flaky TestIndexSplitAndScatterWithStats#170661

Open
michae2 wants to merge 1 commit into
cockroachdb:masterfrom
michae2:fix-index-split-scatter-stats-cache
Open

sql: fix flaky TestIndexSplitAndScatterWithStats#170661
michae2 wants to merge 1 commit into
cockroachdb:masterfrom
michae2:fix-index-split-scatter-stats-cache

Conversation

@michae2
Copy link
Copy Markdown
Collaborator

@michae2 michae2 commented May 20, 2026

The test was flaky because the stats cache could contain a stale entry (populated during INSERT planning) when MaybeSplitIndexSpans ran during CREATE INDEX. Despite its name, GetFreshTableStats returns cached data without checking whether stats have been updated. The async cache refresh triggered by CREATE STATISTICS may not complete in time.

Fix by invalidating the stats cache on all nodes after CREATE STATISTICS, forcing a fresh read from the database.

Fixes: #170609

Release note: None

The test was flaky because the stats cache could contain a stale entry
(populated during INSERT planning) when MaybeSplitIndexSpans ran during
CREATE INDEX. Despite its name, GetFreshTableStats returns cached data
without checking whether stats have been updated. The async cache
refresh triggered by CREATE STATISTICS may not complete in time.

Fix by invalidating the stats cache on all nodes after CREATE STATISTICS,
forcing a fresh read from the database.

Fixes: cockroachdb#170609

Release note: None

Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
@michae2 michae2 requested review from a team, andyyang890, fqazi and mw5h May 20, 2026 16:43
@trunk-io
Copy link
Copy Markdown
Contributor

trunk-io Bot commented May 20, 2026

Merging to master in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sql: TestIndexSplitAndScatterWithStats failed

2 participants