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

ddl: fix admin check table error after rename index with scalar function #56060

Merged
merged 5 commits into from
Sep 13, 2024

Conversation

joechenrh
Copy link
Contributor

@joechenrh joechenrh commented Sep 13, 2024

What problem does this PR solve?

Issue Number: close #56045

Problem Summary:

What changed and how does it work?

renameIndexes didn't rename generated columns previously, causing error during buildPhysicalIndexLookUpReader.

To make the newly added test works, we don't clear idxPart.Expr (which is shallow copied from stmt) in BuildHiddenColumnInfo. Since this stmt will be used twice.

err := d.realExecutor.CreateTable(ctx, stmt)
if err != nil {
return err
}
// some unit test will also check warnings, we reset the warnings after SchemaTracker use session context again.
count := ctx.GetSessionVars().StmtCtx.WarningCount()
// backup old session variables because CreateTable will change them.
enableClusteredIndex := ctx.GetSessionVars().EnableClusteredIndex
err = d.tracker.CreateTable(ctx, stmt)

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 release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 13, 2024
Copy link

tiprow bot commented Sep 13, 2024

Hi @joechenrh. 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.

@joechenrh
Copy link
Contributor Author

/ok-to-test

@ti-chi-bot ti-chi-bot bot added the ok-to-test Indicates a PR is ready to be tested. label Sep 13, 2024
@joechenrh
Copy link
Contributor Author

/retest

Copy link

codecov bot commented Sep 13, 2024

Codecov Report

Attention: Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.

Project coverage is 56.9197%. Comparing base (b3095dc) to head (270f026).
Report is 11 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #56060         +/-   ##
=================================================
- Coverage   72.8796%   56.9197%   -15.9600%     
=================================================
  Files          1604       1758        +154     
  Lines        446775     632916     +186141     
=================================================
+ Hits         325608     360254      +34646     
- Misses       101113     247857     +146744     
- Partials      20054      24805       +4751     
Flag Coverage Δ
integration 39.5935% <81.8181%> (?)
unit 72.1160% <90.9090%> (+0.1382%) ⬆️

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

Components Coverage Δ
dumpling 52.9567% <ø> (ø)
parser ∅ <ø> (∅)
br 62.0003% <ø> (+16.2999%) ⬆️

@joechenrh
Copy link
Contributor Author

/retest

@lance6716
Copy link
Contributor

To make the newly added test works, we don't clear idxPart.Expr (which is shallow copied from stmt) in BuildHiddenColumnInfo. Since this stmt will be used twice.

I think it's not worthy to change the code logic. You can call Checker.Disable / Enable for this test. There are other places that the original statement is changed inside DDL so we need to disable checker. And please write a unit test in pkg/ddl/schematracker to make sure the skipped SQL can be executed and SHOW CREATE TABLE is correct. You can refer to TestBitDefaultValues and checkShowCreateTable

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Sep 13, 2024
@ti-chi-bot ti-chi-bot bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. approved and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 13, 2024
@joechenrh
Copy link
Contributor Author

I think it's not worthy to change the code logic. You can call Checker.Disable / Enable for this test. There are other places that the original statement is changed inside DDL so we need to disable checker. And please write a unit test in pkg/ddl/schematracker to make sure the skipped SQL can be executed and SHOW CREATE TABLE is correct. You can refer to TestBitDefaultValues and checkShowCreateTable

May it's not necessary to write test in pkg/ddl/schematracker. Because rename index can be executed without error, and SHOW CREATE TABLE will also return correct info. The error is raised from admin check table.

@lance6716
Copy link
Contributor

lance6716 commented Sep 13, 2024

Anyway, skipped DDL of checker should have a place to test. Otherwise we can't make sure it will always be correct in future

Copy link

ti-chi-bot bot commented Sep 13, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lance6716, wjhuang2016

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 lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Sep 13, 2024
Copy link

ti-chi-bot bot commented Sep 13, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-09-13 08:17:11.070740159 +0000 UTC m=+603500.811164098: ☑️ agreed by wjhuang2016.
  • 2024-09-13 10:14:17.01144916 +0000 UTC m=+610526.751873098: ☑️ agreed by lance6716.

@lance6716
Copy link
Contributor

/retest

Copy link

tiprow bot commented Sep 13, 2024

@joechenrh: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
fast_test_tiprow 270f026 link true /test fast_test_tiprow

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@ti-chi-bot ti-chi-bot bot merged commit f956694 into pingcap:master Sep 13, 2024
24 of 25 checks passed
@joechenrh joechenrh deleted the fix-rename-index branch October 12, 2024 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm ok-to-test Indicates a PR is ready to be tested. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

panic when admin check table
3 participants