Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stats: prevent NaNs in histograms #142022

Closed
yuzefovich opened this issue Feb 26, 2025 · 2 comments · Fixed by #143858
Closed

stats: prevent NaNs in histograms #142022

yuzefovich opened this issue Feb 26, 2025 · 2 comments · Fixed by #143858
Assignees
Labels
A-sql-debug-bundle Issues related to statement bundle improvements A-sql-table-stats Table statistics (and their automatic refresh). branch-release-24.1 Used to mark GA and release blockers, technical advisories, and bugs for 24.1 C-cleanup Tech debt, refactors, loose ends, etc. Solution not expected to significantly change behavior. E-quick-win Likely to be a quick win for someone experienced. O-support Would prevent or help troubleshoot a customer escalation - bugs, missing observability/tooling, docs P-3 Issues/test failures with no fix SLA T-sql-queries SQL Queries Team target-release-24.1.17 target-release-24.3.11 target-release-25.1.5 target-release-25.2.0

Comments

@yuzefovich
Copy link
Member

yuzefovich commented Feb 26, 2025

When running the reproduction from #141448

SET sql_safe_updates = false;

CREATE TABLE seed AS SELECT g AS _float8,
                            g * '1 day'::INTERVAL,
                            g % 2 = 1 AS _bool,
                            g::DECIMAL AS _decimal
                       FROM generate_series(1, 1) AS g;

INSERT INTO seed (_float8, _bool, _decimal) VALUES (0.9, true, 0);

UPDATE seed AS t SET _bool = t._bool AND false;

INSERT INTO seed (_bool, _decimal) VALUES (false, 1.0);

ANALYZE seed;

SHOW STATISTICS FOR TABLE seed;

SHOW HISTOGRAM <id>;

on M1 I'm getting

  upper_bound | range_rows | distinct_range_rows | equal_rows
--------------+------------+---------------------+-------------
  false       |          0 |                   0 |          0
  true        |          0 |                 NaN |          0

NaN is problematic since it then will prohibit the stats inclusion into the stmt bundle due to

stmtEnvCollector: json: unsupported value: NaN

I observed this behavior on two tables when looking into a stmt bundle issue on the customer cluster.

The root cause of the reproduction is being addressed elsewhere, but clearly we have some ways for NaNs to sneak into the histograms, so we should improve things.

Jira issue: CRDB-48121

@yuzefovich yuzefovich added A-sql-debug-bundle Issues related to statement bundle improvements A-sql-table-stats Table statistics (and their automatic refresh). T-sql-queries SQL Queries Team labels Feb 26, 2025
@blathers-crl blathers-crl bot added the C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) label Feb 26, 2025
@github-project-automation github-project-automation bot moved this to Triage in SQL Queries Feb 26, 2025
@cockroachdb cockroachdb deleted a comment from blathers-crl bot Feb 26, 2025
@yuzefovich yuzefovich added C-cleanup Tech debt, refactors, loose ends, etc. Solution not expected to significantly change behavior. and removed C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) labels Feb 26, 2025
@michae2 michae2 added O-support Would prevent or help troubleshoot a customer escalation - bugs, missing observability/tooling, docs P-3 Issues/test failures with no fix SLA E-quick-win Likely to be a quick win for someone experienced. labels Mar 4, 2025
@michae2 michae2 moved this from Triage to 25.2 Release in SQL Queries Mar 4, 2025
@michae2
Copy link
Collaborator

michae2 commented Mar 4, 2025

[triage] this no longer reproduces on master b/c it's fixed, but we should add more checks so that we don't include NaN in histograms. saw this error on 2/200 tables in a recent escalation

Copy link

blathers-crl bot commented Apr 5, 2025

Based on the specified backports for linked PR #143858, I applied the following new label(s) to this issue: branch-release-24.1. Please adjust the labels as needed to match the branches actually affected by this issue, including adding any known older branches.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-debug-bundle Issues related to statement bundle improvements A-sql-table-stats Table statistics (and their automatic refresh). branch-release-24.1 Used to mark GA and release blockers, technical advisories, and bugs for 24.1 C-cleanup Tech debt, refactors, loose ends, etc. Solution not expected to significantly change behavior. E-quick-win Likely to be a quick win for someone experienced. O-support Would prevent or help troubleshoot a customer escalation - bugs, missing observability/tooling, docs P-3 Issues/test failures with no fix SLA T-sql-queries SQL Queries Team target-release-24.1.17 target-release-24.3.11 target-release-25.1.5 target-release-25.2.0
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants