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 expression index with insert causes losing index data #26248

Merged
merged 11 commits into from
Jul 22, 2021

Conversation

wjhuang2016
Copy link
Member

@wjhuang2016 wjhuang2016 commented Jul 14, 2021

Signed-off-by: wjhuang2016 huangwenjun1997@gmail.com

What problem does this PR solve?

Issue Number: close #26213

Problem Summary:
In reorg, we can't get the value of the hidden virtual column, then the index values are wrong.

What is changed and how it works?

For the hidden virtual column, the state is changed from none to public directly.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

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

  • No release note

@ti-chi-bot ti-chi-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 14, 2021
@sre-bot
Copy link
Contributor

sre-bot commented Jul 14, 2021

Please follow PR Title Format:

  • pkg [, pkg2, pkg3]: what's changed

Or if the count of mainly changed packages are more than 3, use

  • *: what's changed

@sre-bot
Copy link
Contributor

sre-bot commented Jul 15, 2021

Please follow PR Title Format:

  • pkg [, pkg2, pkg3]: what's changed

Or if the count of mainly changed packages are more than 3, use

  • *: what's changed

Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
@ti-chi-bot ti-chi-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 15, 2021
@sre-bot
Copy link
Contributor

sre-bot commented Jul 15, 2021

Please follow PR Title Format:

  • pkg [, pkg2, pkg3]: what's changed

Or if the count of mainly changed packages are more than 3, use

  • *: what's changed

@wjhuang2016 wjhuang2016 changed the title test ddl: fix expression index with insert causes losing index data Jul 15, 2021
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
@github-actions github-actions bot added the sig/sql-infra SIG: SQL Infra label Jul 15, 2021
Copy link
Contributor

@AilinKid AilinKid left a comment

Choose a reason for hiding this comment

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

Rest LGTM

ddl/index.go Show resolved Hide resolved
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 21, 2021
ddl/db_test.go Outdated
if job.SchemaState == model.StateDeleteOnly {
if checkErr != nil {
return
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We can put line416-418 after line412, then we can remove this check after every case state.

ddl/db_test.go Outdated
Comment on lines 425 to 432
_, checkErr = tk1.Exec("insert into t1 values (2, 2, 2)")
if checkErr != nil {
return
}
_, checkErr = tk1.Exec("update t1 set c1 = 3 where c2 = 80")
if checkErr != nil {
return
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
_, checkErr = tk1.Exec("insert into t1 values (2, 2, 2)")
if checkErr != nil {
return
}
_, checkErr = tk1.Exec("update t1 set c1 = 3 where c2 = 80")
if checkErr != nil {
return
}
_, checkErr = tk1.Exec("insert into t1 values (2, 2, 2)")
if checkErr == nil {
_, checkErr = tk1.Exec("update t1 set c1 = 3 where c2 = 80")
}

ddl/db_test.go Outdated
if job.SchemaState == model.StateDeleteOnly {
switch job.SchemaState {
case model.StateDeleteOnly:
if job.SchemaState == model.StateDeleteOnly {
Copy link
Contributor

Choose a reason for hiding this comment

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

This if statement is duplicated with line414.

if checkErr != nil {
return
}
_, checkErr = tk1.Exec("delete from t1 where c1 = 40;")
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we add insert and update statements here? This schema state will be running two times.

Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
Signed-off-by: wjhuang2016 <huangwenjun1997@gmail.com>
Copy link
Contributor

@zimulala zimulala left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • AilinKid
  • zimulala

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jul 22, 2021
@zimulala
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 322620f

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jul 22, 2021
@ti-chi-bot ti-chi-bot merged commit cf5e2ff into pingcap:master Jul 22, 2021
ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Jul 22, 2021
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-4.0 in PR #26478

ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Jul 22, 2021
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-5.0 in PR #26479

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression needs-cherry-pick-release-5.0 sig/execution SIG execution sig/sql-infra SIG: SQL Infra size/L Denotes a PR that changes 100-499 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

index data may be lost when creating expression index
6 participants