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: remove panics in execbuilder #99981

Merged
merged 1 commit into from
Apr 3, 2023

Conversation

mgartner
Copy link
Collaborator

This commit replaces panics in execbuilder with returned errors. This
is safer because execbuilder functions are invoked outside the
panic-recoverable Optimizer.Optimize function.

Informs #98786

Release note: None

@mgartner mgartner requested a review from a team as a code owner March 29, 2023 21:25
@blathers-crl
Copy link

blathers-crl bot commented Mar 29, 2023

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

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

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@mgartner
Copy link
Collaborator Author

I've added the backport label because I think this reduces the risk of uncaught panics, but let me know if you disagree.

@mgartner mgartner added the backport-23.1.x Flags PRs that need to be backported to 23.1 label Mar 29, 2023
Copy link
Member

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

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

Do you envision that we'll both keep the existing panic-catching mechanism where it is already present and also prohibit the usage of error propagation via panics? Should we still then introduce panic injection as Drew's PR does? Should we introduce a linter to prohibit the usage of panics in some optimizer packages?

I don't have too strong of an opinion here, but in the vectorized engine I think the panic-catching mechanism of error propagation worked well for us (in comparison to row-by-row engine we're more likely to return an internal error in some unexpected state rather than crash), so I'd lean towards flushing out all the places where Optimize is invoked. It took us some time to do that in the vectorized engine, but I think we now have panic-catches in all (or at least in the most important) places, so personally I'd put more focus on flushing those callsites out.

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

Copy link
Collaborator

@DrewKimball DrewKimball left a comment

Choose a reason for hiding this comment

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

:lgtm: If we decide to go with this method.

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

@mgartner mgartner force-pushed the remove-execbuilder-panics branch 2 times, most recently from 56f7799 to 5b14c23 Compare March 31, 2023 13:05
@mgartner
Copy link
Collaborator Author

Do you envision that we'll both keep the existing panic-catching mechanism where it is already present and also prohibit the usage of error propagation via panics? Should we still then introduce panic injection as Drew's PR does? Should we introduce a linter to prohibit the usage of panics in some optimizer packages?

I don't envision getting rid of most of the panics or panic-catching within the optimizer. But we need to have a more confident understand and respect for which functions can panic and which cannot.

All of execbuilder lives outside the panic-catching of the Optimize function, so it's really not safe to be panicking here - unless we add new panic-catchers. Because execbuilder already returns errors from the Build function, and there were only a handful of panics, it seemed easier and less error-prone to turn all execbuilder panics into errors, than to try to add panic catching.

@mgartner
Copy link
Collaborator Author

I think this is orthogonal to Drew's panic injector, which will help us find uncaught panics in other parts of the optimizer.

@mgartner mgartner added backport-23.1.x Flags PRs that need to be backported to 23.1 and removed backport-23.1.x Flags PRs that need to be backported to 23.1 labels Mar 31, 2023
@mgartner mgartner force-pushed the remove-execbuilder-panics branch from 5b14c23 to 7e7f5ee Compare March 31, 2023 15:57
This commit replaces `panic`s in execbuilder with returned errors. This
is safer because execbuilder functions are invoked outside the
panic-recoverable `Optimizer.Optimize` function.

Release note: None
@mgartner mgartner force-pushed the remove-execbuilder-panics branch from 7e7f5ee to 04f7b0e Compare March 31, 2023 18:17
@yuzefovich
Copy link
Member

I don't envision getting rid of most of the panics or panic-catching within the optimizer. But we need to have a more confident understand and respect for which functions can panic and which cannot.

All of execbuilder lives outside the panic-catching of the Optimize function, so it's really not safe to be panicking here - unless we add new panic-catchers. Because execbuilder already returns errors from the Build function, and there were only a handful of panics, it seemed easier and less error-prone to turn all execbuilder panics into errors, than to try to add panic catching.

Ok, SGTM.

@mgartner
Copy link
Collaborator Author

mgartner commented Apr 3, 2023

bors r+

@craig craig bot merged commit 6cd1f1b into cockroachdb:master Apr 3, 2023
@craig
Copy link
Contributor

craig bot commented Apr 3, 2023

Build succeeded:

@mgartner mgartner deleted the remove-execbuilder-panics branch April 3, 2023 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-23.1.x Flags PRs that need to be backported to 23.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants