Skip to content

sql: fix flaky TestIndexSplitAndScatterWithStats#170661

Merged
trunk-io[bot] merged 1 commit into
cockroachdb:masterfrom
michae2:fix-index-split-scatter-stats-cache
May 27, 2026
Merged

sql: fix flaky TestIndexSplitAndScatterWithStats#170661
trunk-io[bot] merged 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

😎 Merged successfully - details.

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Contributor

@mw5h mw5h left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@mw5h reviewed all commit messages and made 1 comment.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on andyyang890 and fqazi).

@michae2
Copy link
Copy Markdown
Collaborator Author

michae2 commented May 26, 2026

Thanks!

/trunk merge

@trunk-io trunk-io Bot merged commit a081a00 into cockroachdb:master May 27, 2026
25 checks passed
@michae2 michae2 deleted the fix-index-split-scatter-stats-cache branch May 27, 2026 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sql: TestIndexSplitAndScatterWithStats failed

3 participants