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: ddl rollingback error may lead the json unmarshal error(2) #23893

Closed
AilinKid opened this issue Apr 7, 2021 · 1 comment · Fixed by #23903
Closed

ddl: ddl rollingback error may lead the json unmarshal error(2) #23893

AilinKid opened this issue Apr 7, 2021 · 1 comment · Fixed by #23903
Assignees
Labels
severity/critical sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@AilinKid
Copy link
Contributor

AilinKid commented Apr 7, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

Take cancel add index for example, let mock the error code in Line 45 of rollingback.go with hash e1fccc6

func convertAddIdxJob2RollbackJob(t *meta.Meta, job *model.Job, tblInfo *model.TableInfo, indexInfo *model.IndexInfo, err error) (int64, error) {
	job.State = model.JobStateRollingback
        // here
	return 0, errors.New("mock update version and tableInfo error")
	if indexInfo.Primary {
		nullCols, err := getNullColInfos(tblInfo, indexInfo)
		if err != nil {
			return 0, errors.Trace(err)
		}
		for _, col := range nullCols {
			// Field PreventNullInsertFlag flag reset.
			col.Flag &^= mysql.PreventNullInsertFlag
		}
	}

For the sake of manual cancel operation, let hang on StateDeleteOnly in Line507 with index.go for a while in which we can execute admin cancel ddl job jobID in the other client.

	case model.StateDeleteOnly:
		time.Sleep(time.Second * 20)
		// delete only -> write only
		indexInfo.State = model.StateWriteOnly

2. What did you expect to see? (Required)

Since convertAddIdxJob2RollbackJob encounters an error in the internal logic, we should keep the job state as it is (canceling) and record the error count and message wait for the next ddl round. Once the error count is beyond the limitation, it job is canceled directly.

3. What did you see instead (Required)

Since convertAddIdxJob2RollbackJob encounters an error in the internal logic, the job can't be set as JobStateRollingback at every first beginning. That will leads to the rollbacking logic done with something like ERROR 1105 (HY000): json: cannot unmarshal bool into Go value of type string

4. What is your TiDB version? (Required)

master

@AilinKid AilinKid added the type/bug The issue is confirmed as a bug. label Apr 7, 2021
@AilinKid AilinKid changed the title ddl: ddl rollingback may lead the json unmarshal error ddl: ddl rollingback error may lead the json unmarshal error Apr 7, 2021
@AilinKid AilinKid added the sig/sql-infra SIG: SQL Infra label Apr 7, 2021
@AilinKid AilinKid self-assigned this Apr 7, 2021
@AilinKid AilinKid changed the title ddl: ddl rollingback error may lead the json unmarshal error ddl: ddl rollingback error may lead the json unmarshal error(2) Apr 7, 2021
@ti-srebot
Copy link
Contributor

Please edit this comment or add a new comment to complete the following information

Not a bug

  1. Remove the 'type/bug' label
  2. Add notes to indicate why it is not a bug

Duplicate bug

  1. Add the 'type/duplicate' label
  2. Add the link to the original bug

Bug

Note: Make Sure that 'component', and 'severity' labels are added
Example for how to fill out the template: #20100

1. Root Cause Analysis (RCA) (optional)

2. Symptom (optional)

3. All Trigger Conditions (optional)

4. Workaround (optional)

5. Affected versions

6. Fixed versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/critical sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants