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

expression: Fix optimizer panic in evaluate expr with null #57403

Conversation

windtalker
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #55886

Problem Summary:

What changed and how does it work?

  1. Both evaluateExprWithNull and evaluateExprWithNullInNullRejectCheck use NewFunction instead of NewFunctionInternal to create a scalar function
  2. let EvaluateExprWithNull return error if some error happens inside EvaluateExprWithNull
  3. The caller of EvaluateExprWithNull need to decide how to handle this error, currently, all the callers of EvaluateExprWithNull are optimizer, and will ignore the error

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-triage-completed release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 15, 2024
Copy link

tiprow bot commented Nov 15, 2024

Hi @windtalker. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link

codecov bot commented Nov 15, 2024

Codecov Report

Attention: Patch coverage is 34.14634% with 27 lines in your changes missing coverage. Please review.

Project coverage is 73.4283%. Comparing base (4a6bf46) to head (687c441).
Report is 24 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #57403        +/-   ##
================================================
+ Coverage   72.8367%   73.4283%   +0.5915%     
================================================
  Files          1672       1672                
  Lines        462640     462699        +59     
================================================
+ Hits         336972     339752      +2780     
+ Misses       104878     102254      -2624     
+ Partials      20790      20693        -97     
Flag Coverage Δ
integration 43.3396% <26.8292%> (?)
unit 72.2483% <34.1463%> (+0.0333%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.7673% <ø> (ø)
parser ∅ <ø> (∅)
br 45.1195% <ø> (+0.0153%) ⬆️
---- 🚨 Try these New Features:

Copy link
Contributor

@ghazalfamilyusa ghazalfamilyusa left a comment

Choose a reason for hiding this comment

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

Looks good overall. My comments is about adding the test to
the original pkg/planner/core/casetest/rule/testdata/outer2inner_in.json test and testing the expression evaluation in the non-optimizer path.

@@ -3952,3 +3952,15 @@ func TestIssue55885(t *testing.T) {

tk.MustQuery("SELECT subq_0.c3 as c1 FROM (select c_a90ol as c3, c_a90ol as c4, var_pop(cast(c__qy as double)) over (partition by c_a90ol, c_s order by c_z) as c5 from t_jg8o limit 65) as subq_0 LIMIT 37")
}

func TestIssue55886(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add this test to pkg/planner/core/casetest/rule/testdata/outer2inner_in.json with explain?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Signed-off-by: xufei <[email protected]>
Signed-off-by: xufei <[email protected]>
Signed-off-by: xufei <[email protected]>
Signed-off-by: xufei <[email protected]>
Signed-off-by: xufei <[email protected]>
@windtalker windtalker force-pushed the fix_optimizer_panic_in_EvaluateExprWithNull branch from bc81ef1 to f764b5c Compare November 18, 2024 02:03
@windtalker
Copy link
Contributor Author

Looks good overall. My comments is about adding the test to the original pkg/planner/core/casetest/rule/testdata/outer2inner_in.json test and testing the expression evaluation in the non-optimizer path.

EvaluateExprWithNull is now only used by optimizer, but I add a ut to test that EvaluateExprWithNull do return error if there is some error happens inside.

Signed-off-by: xufei <[email protected]>
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Nov 19, 2024
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Nov 19, 2024
Copy link

ti-chi-bot bot commented Nov 19, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-11-15 18:02:04.357365674 +0000 UTC m=+638486.548234663: ✖️🔁 reset by ghazalfamilyusa.
  • 2024-11-19 00:46:54.977657287 +0000 UTC m=+921977.168526283: ☑️ agreed by ghazalfamilyusa.
  • 2024-11-19 03:01:13.06702823 +0000 UTC m=+930035.257897228: ☑️ agreed by XuHuaiyu.

Copy link

ti-chi-bot bot commented Nov 19, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AilinKid, ghazalfamilyusa, XuHuaiyu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added the approved label Nov 19, 2024
@ti-chi-bot ti-chi-bot bot merged commit 35d5739 into pingcap:master Nov 19, 2024
24 checks passed
@ti-chi-bot ti-chi-bot bot added the needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. label Nov 19, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.5: #57517.

@windtalker windtalker deleted the fix_optimizer_panic_in_EvaluateExprWithNull branch November 19, 2024 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
5 participants