@@ -44,8 +44,12 @@ const (
44
44
var (
45
45
checkTaskFinishedInterval = 500 * time .Millisecond
46
46
nonRetrySQLTime = 1
47
- retrySQLTimes = 30
48
- retrySQLInterval = 3 * time .Second
47
+ // RetrySQLTimes is the max retry times when executing SQL.
48
+ RetrySQLTimes = 30
49
+ // RetrySQLInterval is the initial interval between two SQL retries.
50
+ RetrySQLInterval = 3 * time .Second
51
+ // RetrySQLMaxInterval is the max interval between two SQL retries.
52
+ RetrySQLMaxInterval = 30 * time .Second
49
53
)
50
54
51
55
// TaskHandle provides the interface for operations needed by Dispatcher.
@@ -191,7 +195,7 @@ func (d *BaseDispatcher) onReverting() error {
191
195
if prevStageFinished {
192
196
// Finish the rollback step.
193
197
logutil .Logger (d .logCtx ).Info ("update the task to reverted state" )
194
- return d .updateTask (proto .TaskStateReverted , nil , retrySQLTimes )
198
+ return d .updateTask (proto .TaskStateReverted , nil , RetrySQLTimes )
195
199
}
196
200
// Wait all subtasks in this stage finished.
197
201
d .OnTick (d .ctx , d .task )
@@ -321,7 +325,7 @@ func (d *BaseDispatcher) updateTask(taskState string, newSubTasks []*proto.Subta
321
325
logutil .Logger (d .logCtx ).Warn ("updateTask first failed" , zap .String ("from" , prevState ), zap .String ("to" , d .task .State ),
322
326
zap .Int ("retry times" , retryTimes ), zap .Error (err ))
323
327
}
324
- time .Sleep (retrySQLInterval )
328
+ time .Sleep (RetrySQLInterval )
325
329
}
326
330
if err != nil && retryTimes != nonRetrySQLTime {
327
331
logutil .Logger (d .logCtx ).Warn ("updateTask failed" ,
@@ -354,7 +358,7 @@ func (d *BaseDispatcher) dispatchSubTask4Revert(task *proto.Task, meta []byte) e
354
358
for _ , id := range instanceIDs {
355
359
subTasks = append (subTasks , proto .NewSubtask (task .ID , task .Type , id , meta ))
356
360
}
357
- return d .updateTask (proto .TaskStateReverting , subTasks , retrySQLTimes )
361
+ return d .updateTask (proto .TaskStateReverting , subTasks , RetrySQLTimes )
358
362
}
359
363
360
364
func (d * BaseDispatcher ) onNextStage () error {
@@ -377,7 +381,7 @@ func (d *BaseDispatcher) dispatchSubTask(task *proto.Task, metas [][]byte) error
377
381
task .Concurrency = MaxSubtaskConcurrency
378
382
}
379
383
380
- retryTimes := retrySQLTimes
384
+ retryTimes := RetrySQLTimes
381
385
// 2. Special handling for the new tasks.
382
386
if task .State == proto .TaskStatePending {
383
387
// TODO: Consider using TS.
@@ -428,7 +432,7 @@ func (d *BaseDispatcher) dispatchSubTask(task *proto.Task, metas [][]byte) error
428
432
logutil .Logger (d .logCtx ).Debug ("create subtasks" , zap .String ("instanceID" , instanceID ))
429
433
subTasks = append (subTasks , proto .NewSubtask (task .ID , task .Type , instanceID , meta ))
430
434
}
431
- return d .updateTask (proto .TaskStateRunning , subTasks , retrySQLTimes )
435
+ return d .updateTask (proto .TaskStateRunning , subTasks , RetrySQLTimes )
432
436
}
433
437
434
438
func (d * BaseDispatcher ) handlePlanErr (err error ) error {
@@ -438,7 +442,7 @@ func (d *BaseDispatcher) handlePlanErr(err error) error {
438
442
}
439
443
d .task .Error = err
440
444
// state transform: pending -> failed.
441
- return d .updateTask (proto .TaskStateFailed , nil , retrySQLTimes )
445
+ return d .updateTask (proto .TaskStateFailed , nil , RetrySQLTimes )
442
446
}
443
447
444
448
// GenerateSchedulerNodes generate a eligible TiDB nodes.
0 commit comments