Repository navigation
fix(plan): sanitize non-finite plan stats - #24672
Merged
XuPeng-SH merged 5 commits intoMay 28, 2026
Merged
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
approved these changes
May 28, 2026
XuPeng-SH
left a comment
Contributor
There was a problem hiding this comment.
No material issues found after reviewing the cherry-pick and the regression coverage.
1 of 7 tasks
XuPeng-SH
added a commit
that referenced
this pull request
May 28, 2026
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue #24520 ## What this PR does / why we need it: Cherry-pick PR #24672 to 3.0-dev. 3.0-dev is affected by the same defect: optimizer stats can produce non-finite (`+Inf`/`NaN`) selectivity via unchecked divisions in `pkg/sql/plan/stats.go`, which then breaks plan JSON marshaling on CN (`serialize plan to json error: json: unsupported value: +Inf`) and drops client connections under load. This PR prevents non-finite planner statistics from leaking into plan JSON and cost estimation paths by: - guarding stats ratio calculations against division by zero and non-finite results; - sanitizing non-finite float values before plan JSON marshaling; - clamping expression and join selectivity to the valid [0, 1] range; - clamping ANTI JOIN right-side selectivity before computing output rows; - adding regression coverage for zero stats, year(...) equality selectivity, NOT/JOIN propagation, ANTI JOIN, and JSON marshal sanitization. Conflicts were resolved to match 3.0-dev (e.g. `w.Stats` accessor naming, `pb/plan` import alias, and dropping the FUNCTION_SCAN IndexReaderParam path absent in 3.0-dev). --------- Co-authored-by: XuPeng-SH <[email protected]> Co-authored-by: Claude Opus 4.7 <[email protected]>
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Which issue(s) this PR fixes:
issue #24520
What this PR does / why we need it:
Cherry-pick PR #24643 to 4.0-dev.
This PR prevents non-finite planner statistics from leaking into plan JSON and cost estimation paths by: