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 corrupted table meta after rollback a reorganize partition job #42479

Merged
merged 2 commits into from
Mar 23, 2023

Conversation

lcwangchao
Copy link
Collaborator

@lcwangchao lcwangchao commented Mar 22, 2023

What problem does this PR solve?

Issue Number: close #42448

The reorganize partition job did not handle the cancel operation. After admin cancel ddl jobs ... command, DDL job will be set to cancelled directly without rolling back.

What is changed and how it works?

Do rolling back when job is cancelled by user.

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

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

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Mar 22, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • bb7133
  • mjonss

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 do-not-merge/needs-triage-completed release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-cherry-pick-release-7.0 and removed do-not-merge/needs-triage-completed labels Mar 22, 2023
@lcwangchao
Copy link
Collaborator Author

/retest

Copy link
Contributor

@mjonss mjonss left a comment

Choose a reason for hiding this comment

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

LGTM, just some suggestion for more stable test.

Comment on lines 173 to 198
go func() {
tk2 := testkit.NewTestKit(t, store)
tk2.MustExec("use test")
err := tk2.ExecToErr("alter table t1 reorganize partition p0, p1, p2, p3, p4 into( partition pnew values less than (10000000))")
ddlDone <- err
}()

showDDLJobStart := time.Now()
jobID := ""
schemaState := ""
for time.Since(showDDLJobStart) < time.Minute {
rows := tk.MustQuery("admin show ddl jobs where JOB_TYPE='alter table reorganize partition'").Rows()
if len(rows) == 0 {
time.Sleep(100 * time.Millisecond)
continue
}

require.Equal(t, 1, len(rows))
jobID = rows[0][0].(string)
schemaState = rows[0][4].(string)
if schemaState != "write reorganization" {
time.Sleep(500 * time.Millisecond)
continue
}
break
}
Copy link
Contributor

Choose a reason for hiding this comment

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

One could also use a hook/callback for better control, like in this example or this example.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea! I've updated the PR

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Mar 22, 2023
Copy link
Member

@bb7133 bb7133 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 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 Mar 23, 2023
@bb7133
Copy link
Member

bb7133 commented Mar 23, 2023

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 9b8fb14

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Mar 23, 2023
@ti-chi-bot ti-chi-bot removed the status/can-merge Indicates a PR has been approved by a committer. label Mar 23, 2023
@lcwangchao
Copy link
Collaborator Author

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 061851f

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Mar 23, 2023
@ti-chi-bot ti-chi-bot merged commit f572502 into pingcap:master Mar 23, 2023
@ti-chi-bot
Copy link
Member

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

@lcwangchao lcwangchao deleted the fix_42448 branch March 23, 2023 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-7.0 release-note-none Denotes a PR that doesn't merit a release note. 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.

add index for partition table find next partition ID failed
4 participants