Skip to content

Commit

Permalink
ddl: fix invailid ddl job panic (pingcap#7940)
Browse files Browse the repository at this point in the history
  • Loading branch information
crazycs520 committed Oct 19, 2018
1 parent 6c50eba commit 74b8cf9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ddl/ddl_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ func (d *ddl) runDDLJob(t *meta.Meta, job *model.Job) (ver int64, err error) {
default:
// Invalid job, cancel it.
job.State = model.JobStateCancelled
err = errInvalidDDLJob.Gen("invalid ddl job %v", job)
err = errInvalidDDLJob.Gen("invalid ddl job type: %v", job.Type)
}

// Save errors in job, so that others can know errors happened.
Expand Down
18 changes: 18 additions & 0 deletions ddl/ddl_worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,24 @@ func (s *testDDLSuite) TestTableError(c *C) {

}

func (s *testDDLSuite) TestInvalidDDLJob(c *C) {
store := testCreateStore(c, "test_invalid_ddl_job_type_error")
defer store.Close()
d := testNewDDL(context.Background(), nil, store, nil, nil, testLease)
defer d.Stop()
ctx := testNewContext(d)

job := &model.Job{
SchemaID: 0,
TableID: 0,
Type: model.ActionNone,
BinlogInfo: &model.HistoryInfo{},
Args: []interface{}{},
}
err := d.doDDLJob(ctx, job)
c.Assert(err.Error(), Equals, "[ddl:3]invalid ddl job type: none")
}

func (s *testDDLSuite) TestForeignKeyError(c *C) {
store := testCreateStore(c, "test_foreign_key_error")
defer store.Close()
Expand Down

0 comments on commit 74b8cf9

Please sign in to comment.