Skip to content

Commit

Permalink
ddl: fix invailid ddl job panic (#7940)
Browse files Browse the repository at this point in the history
  • Loading branch information
crazycs520 authored and ngaut committed Oct 19, 2018
1 parent 1028164 commit 6840e17
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 @@ -510,7 +510,7 @@ func (w *worker) runDDLJob(d *ddlCtx, t *meta.Meta, job *model.Job) (ver int64,
default:
// Invalid job, cancel it.
job.State = model.JobStateCancelled
err = errInvalidDDLJob.GenWithStack("invalid ddl job %v", job)
err = errInvalidDDLJob.GenWithStack("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 @@ -136,6 +136,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 6840e17

Please sign in to comment.