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

opt: fix internal error due to node with MaxCost added to memo #84366

Merged
merged 1 commit into from
Jul 13, 2022

Conversation

rytaft
Copy link
Collaborator

@rytaft rytaft commented Jul 13, 2022

This commit fixes an internal error caused by calculating the
selectivity of a join as NaN. The solution is to avoid dividing by
0 when calculating the selectivity.

Fixes #84236

Release note (bug fix): Fixed an internal error "node ... with
MaxCost added to the memo" that could occur during planning when
calculating the cardinality of an outer join when one of the inputs
had 0 rows.

This commit fixes an internal error caused by calculating the
selectivity of a join as NaN. The solution is to avoid dividing by
0 when calculating the selectivity.

Fixes cockroachdb#84236

Release note (bug fix): Fixed an internal error "node ... with
MaxCost added to the memo" that could occur during planning when
calculating the cardinality of an outer join when one of the inputs
had 0 rows.
@rytaft rytaft requested review from msirek and michae2 July 13, 2022 17:13
@rytaft rytaft requested a review from a team as a code owner July 13, 2022 17:13
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@michae2 michae2 left a comment

Choose a reason for hiding this comment

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

:lgtm: Ah, nice.

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @msirek)

Copy link
Collaborator Author

@rytaft rytaft left a comment

Choose a reason for hiding this comment

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

TFTR!

bors r+

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @msirek)

Copy link
Collaborator

@mgartner mgartner left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @msirek and @rytaft)


pkg/sql/opt/memo/statistics_builder.go line 4083 at r1 (raw file):

) props.Selectivity {
	outRowCount := nonNullSelectivity.AsFloat()*(inputRowCount-inputNullCount) + nullSelectivity.AsFloat()*inputNullCount
	sel := props.MakeSelectivityFromFraction(outRowCount, inputRowCount)

Would it aid in future debugging if the selectivityInRange panicked with an assertion error if math.IsNan(sel)?

@rytaft
Copy link
Collaborator Author

rytaft commented Jul 13, 2022

pkg/sql/opt/memo/statistics_builder.go line 4083 at r1 (raw file):

Previously, mgartner (Marcus Gartner) wrote…

Would it aid in future debugging if the selectivityInRange panicked with an assertion error if math.IsNan(sel)?

Yea good call -- I will add that in a separate PR since bors is already running on this one

@craig
Copy link
Contributor

craig bot commented Jul 13, 2022

Build succeeded:

@craig craig bot merged commit 351498d into cockroachdb:master Jul 13, 2022
@blathers-crl
Copy link

blathers-crl bot commented Jul 13, 2022

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


error creating merge commit from 995c71b to blathers/backport-release-21.2-84366: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 21.2.x failed. See errors above.


error creating merge commit from 995c71b to blathers/backport-release-22.1-84366: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 22.1.x failed. See errors above.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

rytaft added a commit to rytaft/cockroach that referenced this pull request Jul 13, 2022
This commit addresses a leftover comment from cockroachdb#84366.

Release note: None
craig bot pushed a commit that referenced this pull request Jul 13, 2022
84360: sql/sem/builtins: move definitions map to new package r=Xiang-Gu a=ajwerner

Previously, the definition of builtin functions live in the `builtins`
package. This was undesirable because various other packages need to
acceess builtins properties by name, but it has a been a headache to
achieve this without importing the `builtins` package, which stands
pretty high in the dependecy chain (e.g. `seqexpr`, `memo`).

This PR moves builtins definition into a new registry package that the
`builtins` package calls to register builtin functions, which happens
in the `init()` function. This way, other lower level packages, who
wish to access builtins properties, need only to import the newly
created `builtinsregistry` package.

Release note: None

84376: opt: add assertion that selectivity is never NaN r=rytaft a=rytaft

This commit addresses a leftover comment from #84366.

Release note: None

84392: roachtest: wait for a 5x replication instead of 3x r=lidorcarmel a=lidorcarmel

Flaky test: we wait for a 3x replication and then drain 3 nodes. Then we
sometimes have ranges with all 3 replicas on those 3 nodes, stuck forever.

Instead the test should wait for a 5x replication before starting the drain.

Fixes #84128.

Release note: None

Co-authored-by: Andrew Werner <[email protected]>
Co-authored-by: Rebecca Taft <[email protected]>
Co-authored-by: Lidor Carmel <[email protected]>
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.

opt: internal error: node sort with MaxCost added to the memo
4 participants