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

DecodeArgs relies on a wrong behavior of json.Unmarshal #889

Closed
bobotu opened this issue Jun 8, 2020 · 0 comments · Fixed by #890
Closed

DecodeArgs relies on a wrong behavior of json.Unmarshal #889

bobotu opened this issue Jun 8, 2020 · 0 comments · Fixed by #890
Labels
severity/minor type/bug Something isn't working

Comments

@bobotu
Copy link
Contributor

bobotu commented Jun 8, 2020

Bug Report

In Go 1.15 (master branch), TiDB's DDL cannot work correctly and DDL related unit-test all failed.

The root cause is Job.DecodeArgs relies on the wrong behavior of json.Unmarshal, and this bug is fixed in Go 1.15.

The docs read:

To unmarshal a JSON array into a slice, Unmarshal resets the slice length to zero and then appends each element to the slice.

This means the value in args doesn't matter, and the value in args will be replaced by an interface{}(nil).

parser/model/ddl.go

Lines 284 to 288 in fb51991

func (job *Job) DecodeArgs(args ...interface{}) error {
job.Args = args
err := json.Unmarshal(job.RawArgs, &job.Args)
return errors.Trace(err)
}

See golang/go#39427 for a more detailed discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/minor type/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants