Skip to content

release-26.1: stats: respect table-level params in auto stats refresher#167680

Merged
trunk-io[bot] merged 1 commit intocockroachdb:release-26.1from
yuzefovich:blathers/backport-release-26.1-167540
Apr 7, 2026
Merged

release-26.1: stats: respect table-level params in auto stats refresher#167680
trunk-io[bot] merged 1 commit intocockroachdb:release-26.1from
yuzefovich:blathers/backport-release-26.1-167540

Conversation

@yuzefovich
Copy link
Copy Markdown
Member

@yuzefovich yuzefovich commented Apr 7, 2026

Backport 1/1 commits from #167540 on behalf of @yuzefovich.


This commit fixes a bug where we could ignore sql_stats_automatic_full_collection_enabled and sql_stats_automatic_partial_collection_enabled table-level storage parameters in the auto stats refresher. In particular, we had a couple of helper methods that would take a TableDescriptor as an argument, and if that happens to be nil, then we'd default to the corresponding cluster setting. The thing is that we don't always fetch the TableDescriptor (we only do so only if the maybeRefreshStats goroutine has been running for at least 1 minute, meaning that there were previous long stats collections during the current refresh cycle). This commit fixes the bug by propagating the table-level parameters directly which side-steps the nil TableDescriptor issue (we do keep all overrides in the global map).

Note that we probably could have caught this bug in the logic tests, but we reduce DefaultRefreshInterval to 1ms in there, so we happened to fetch the TableDescriptor most (all?) of the time.

Epic: None

Release note (bug fix): Previously, CockroachDB might not have respected the table-level parameters sql_stats_automatic_full_collection_enabled and sql_stats_automatic_partial_collection_enabled and defaulted to using the corresponding cluster settings when deciding whether to perform automatic statistic collection on a table. This is now fixed.


Release justification: bug fix.

@blathers-crl blathers-crl Bot added blathers-backport This is a backport that Blathers created automatically. O-robot Originated from a bot. labels Apr 7, 2026
@yuzefovich yuzefovich added O-robot Originated from a bot. blathers-backport This is a backport that Blathers created automatically. labels Apr 7, 2026
@blathers-crl blathers-crl Bot requested a review from michae2 April 7, 2026 00:07
@yuzefovich yuzefovich requested a review from a team as a code owner April 7, 2026 00:07
@trunk-io
Copy link
Copy Markdown
Contributor

trunk-io Bot commented Apr 7, 2026

😎 Merged successfully - details.

@blathers-crl
Copy link
Copy Markdown

blathers-crl Bot commented Apr 7, 2026

Thanks for opening a backport.

Before merging, please confirm that the change does not break backwards compatibility and otherwise complies with the backport policy. Include a brief release justification in the PR description explaining why the backport is appropriate. All backports must be reviewed by the TL for the owning area. While the stricter LTS policy does not yet apply, please exercise judgment and consider gating non-critical changes behind a disabled-by-default feature flag when appropriate.

@blathers-crl blathers-crl Bot added backport Label PR's that are backports to older release branches T-sql-queries SQL Queries Team labels Apr 7, 2026
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@yuzefovich yuzefovich requested review from mw5h and removed request for a team and michae2 April 7, 2026 00:21
This commit fixes a bug where we could ignore
`sql_stats_automatic_full_collection_enabled` and
`sql_stats_automatic_partial_collection_enabled` table-level storage
parameters in the auto stats refresher. In particular, we had a couple
of helper methods that would take a TableDescriptor as an argument, and
if that happens to be nil, then we'd default to the corresponding
cluster setting. The thing is that we don't always fetch the
TableDescriptor (we only do so only if the `maybeRefreshStats` goroutine
has been running for at least 1 minute, meaning that there were previous
long stats collections during the current refresh cycle). This commit
fixes the bug by propagating the table-level parameters directly which
side-steps the nil TableDescriptor issue (we do keep all overrides in
the global map).

Note that we probably could have caught this bug in the logic tests, but
we reduce DefaultRefreshInterval to 1ms in there, so we happened to
fetch the TableDescriptor most (all?) of the time.

Release note (bug fix): Previously, CockroachDB might not have respected
the table-level parameters `sql_stats_automatic_full_collection_enabled`
and `sql_stats_automatic_partial_collection_enabled` and defaulted to
using the corresponding cluster settings when deciding whether to
perform automatic statistic collection on a table. This is now fixed.
@yuzefovich yuzefovich force-pushed the blathers/backport-release-26.1-167540 branch from 9b2b78f to 194a0c7 Compare April 7, 2026 00:28
@trunk-io trunk-io Bot merged commit 4f28e45 into cockroachdb:release-26.1 Apr 7, 2026
17 checks passed
@yuzefovich yuzefovich deleted the blathers/backport-release-26.1-167540 branch April 7, 2026 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Label PR's that are backports to older release branches blathers-backport This is a backport that Blathers created automatically. O-robot Originated from a bot. T-sql-queries SQL Queries Team target-release-26.1.4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants