本文整理匯總了Golang中github.com/pingcap/tidb/model.Job.Error方法的典型用法代碼示例。如果您正苦於以下問題:Golang Job.Error方法的具體用法?Golang Job.Error怎麽用?Golang Job.Error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/pingcap/tidb/model.Job
的用法示例。
在下文中一共展示了Job.Error方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: runDDLJob
// runDDLJob runs a DDL job.
func (d *ddl) runDDLJob(t *meta.Meta, job *model.Job) {
log.Infof("[ddl] run DDL job %s", job)
if job.IsFinished() {
return
}
if job.State != model.JobRollback {
job.State = model.JobRunning
}
var err error
switch job.Type {
case model.ActionCreateSchema:
err = d.onCreateSchema(t, job)
case model.ActionDropSchema:
err = d.onDropSchema(t, job)
case model.ActionCreateTable:
err = d.onCreateTable(t, job)
case model.ActionDropTable:
err = d.onDropTable(t, job)
case model.ActionAddColumn:
err = d.onAddColumn(t, job)
case model.ActionDropColumn:
err = d.onDropColumn(t, job)
case model.ActionModifyColumn:
err = d.onModifyColumn(t, job)
case model.ActionAddIndex:
err = d.onCreateIndex(t, job)
case model.ActionDropIndex:
err = d.onDropIndex(t, job)
case model.ActionAddForeignKey:
err = d.onCreateForeignKey(t, job)
case model.ActionDropForeignKey:
err = d.onDropForeignKey(t, job)
case model.ActionTruncateTable:
err = d.onTruncateTable(t, job)
default:
// Invalid job, cancel it.
job.State = model.JobCancelled
err = errInvalidDDLJob.Gen("invalid ddl job %v", job)
}
// Save errors in job, so that others can know errors happened.
if err != nil {
// If job is not cancelled, we should log this error.
if job.State != model.JobCancelled {
log.Errorf("[ddl] run ddl job err %v", errors.ErrorStack(err))
} else {
log.Infof("[ddl] the job is normal to cancel because %v", errors.ErrorStack(err))
}
job.Error = toTError(err)
job.ErrorCount++
}
}
示例2: runDDLJob
func (d *ddl) runDDLJob(t *meta.Meta, job *model.Job) {
if job.IsFinished() {
return
}
job.State = model.JobRunning
var err error
switch job.Type {
case model.ActionCreateSchema:
err = d.onCreateSchema(t, job)
case model.ActionDropSchema:
err = d.onDropSchema(t, job)
case model.ActionCreateTable:
err = d.onCreateTable(t, job)
case model.ActionDropTable:
err = d.onDropTable(t, job)
case model.ActionAddColumn:
err = d.onAddColumn(t, job)
case model.ActionDropColumn:
err = d.onDropColumn(t, job)
case model.ActionAddIndex:
err = d.onCreateIndex(t, job)
case model.ActionDropIndex:
err = d.onDropIndex(t, job)
case model.ActionAddForeignKey:
err = d.onCreateForeignKey(t, job)
case model.ActionDropForeignKey:
err = d.onDropForeignKey(t, job)
default:
// invalid job, cancel it.
job.State = model.JobCancelled
err = errInvalidDDLJob.Gen("invalid ddl job %v", job)
}
// saves error in job, so that others can know error happens.
if err != nil {
// if job is not cancelled, we should log this error.
if job.State != model.JobCancelled {
log.Errorf("run ddl job err %v", errors.ErrorStack(err))
}
job.Error = err.Error()
job.ErrorCount++
}
}
示例3: runBgJob
// runBgJob runs a background job.
func (d *ddl) runBgJob(t *meta.Meta, job *model.Job) {
job.State = model.JobRunning
var err error
switch job.Type {
case model.ActionDropSchema:
err = d.delReorgSchema(t, job)
case model.ActionDropTable, model.ActionTruncateTable:
err = d.delReorgTable(t, job)
default:
job.State = model.JobCancelled
err = errInvalidBgJob
}
if err != nil {
if job.State != model.JobCancelled {
log.Errorf("[ddl] run background job err %v", errors.ErrorStack(err))
}
job.Error = toTError(err)
job.ErrorCount++
}
}
示例4: runJob
func (d *ddl) runJob(job *model.Job) error {
if job.State == model.JobDone || job.State == model.JobCancelled {
return nil
}
job.State = model.JobRunning
var err error
switch job.Type {
case model.ActionCreateSchema:
case model.ActionDropSchema:
case model.ActionCreateTable:
case model.ActionDropTable:
case model.ActionAddColumn:
case model.ActionDropColumn:
case model.ActionAddIndex:
case model.ActionDropIndex:
case model.ActionAddConstraint:
case model.ActionDropConstraint:
default:
return errors.Errorf("invalid job %v", job)
}
// if err and inner doesn't cancel job, return err.
if err != nil {
if job.State != model.JobCancelled {
return errors.Trace(err)
}
job.Error = err.Error()
} else {
job.State = model.JobDone
}
return nil
}