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 the covert job to rollingback job #23903

Merged
merged 16 commits into from
Apr 16, 2021

Conversation

AilinKid
Copy link
Contributor

@AilinKid AilinKid commented Apr 7, 2021

Signed-off-by: AilinKid 314806019@qq.com

What problem does this PR solve?

Issue Number: close #23893

Once convertJob2RollbackJob meets error, the job state can't be set as JobStateRollingback since
job state and args may not be correctly overwritten. The job will be fetched to run with the canceling
state again. So we should check the error count here.

What is changed and how it works?

What's Changed:

  1. change all the rollingback assignments to the last step in all ddl canceling logic.
    This is aim to get rid of invalid job state and job args, while the job is assigned with rollingback state, which will lead errors in following rollingback logic, for example, json unmarshal error.

  2. Add error count check and force it be canceled in convertJob2RollbackJob
    This is aim to get rid of the infinite loop of canceling action once convertJob2RollbackJob gets an error.

Related changes

  • PR to update pingcap/docs/pingcap/docs-cn:
  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test
  • Integration test

Release note

  • ddl: fix the covert job to rollingback job

Signed-off-by: AilinKid <314806019@qq.com>
@ti-chi-bot ti-chi-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 7, 2021
@github-actions github-actions bot added the sig/sql-infra SIG: SQL Infra label Apr 7, 2021
@AilinKid AilinKid requested review from zimulala, crazycs520 and tangenta and removed request for zimulala April 7, 2021 11:24
AilinKid added 4 commits April 7, 2021 20:04
Signed-off-by: AilinKid <314806019@qq.com>
Signed-off-by: AilinKid <314806019@qq.com>
}
errorCount := variable.GetDDLErrorCountLimit()
if job.ErrorCount > errorCount {
msg := fmt.Sprintf("job being converted to rollback job errors and error count beyond the limitation %d, cancelled", errorCount)
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
msg := fmt.Sprintf("job being converted to rollback job errors and error count beyond the limitation %d, cancelled", errorCount)
logutil.Logger(w.logCtx).Warn("[ddl] rollback DDL job error count exceed the limit, cancelled it now", zap.Int64("jobID", job.ID), zap.Int64("errorCountLimit", errorCount))

Unify the logs in runDDL and this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed

errorCount := variable.GetDDLErrorCountLimit()
if job.ErrorCount > errorCount {
logutil.Logger(w.logCtx).Warn("[ddl] rollback DDL job error count exceed the limit, cancelled it now", zap.Int64("jobID", job.ID), zap.Int64("errorCountLimit", errorCount))
job.Error = toTError(errors.New(fmt.Sprintf(fmt.Sprintf(" rollback DDL job error count exceed the limit %d, cancelled it now", errorCount))))
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
job.Error = toTError(errors.New(fmt.Sprintf(fmt.Sprintf(" rollback DDL job error count exceed the limit %d, cancelled it now", errorCount))))
job.Error = toTError(errors.New(fmt.Sprintf(fmt.Sprintf("rollback DDL job error count exceed the limit %d, cancelled it now", errorCount))))

Copy link
Contributor

@tangenta tangenta 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

@tangenta
Copy link
Contributor

/lgtm

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Apr 15, 2021
.
Signed-off-by: AilinKid <314806019@qq.com>
@crazycs520
Copy link
Contributor

/lgtm

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • crazycs520
  • tangenta

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 writing /lgtm in a comment.
Reviewer can cancel approval by writing /lgtm cancel in a comment.

@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 Apr 15, 2021
@crazycs520
Copy link
Contributor

/approve

@crazycs520
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 0d3e800

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Apr 15, 2021
@AilinKid
Copy link
Contributor Author

/merge

@ti-chi-bot ti-chi-bot merged commit 4db325d into pingcap:master Apr 16, 2021
ti-srebot pushed a commit to ti-srebot/tidb that referenced this pull request Apr 16, 2021
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-5.0 in PR #24080

@AilinKid
Copy link
Contributor Author

AilinKid commented May 7, 2021

/run-cherry-picker

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

cherry pick to release-4.0 in PR #24445

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-5.0 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.

ddl: ddl rollingback error may lead the json unmarshal error(2)
6 participants