diff --git a/lightning/restore/restore.go b/lightning/restore/restore.go index b6e2537cd..2a8fd4a99 100644 --- a/lightning/restore/restore.go +++ b/lightning/restore/restore.go @@ -461,14 +461,20 @@ func (rc *RestoreController) listenCheckpointUpdates() { } func (rc *RestoreController) runPeriodicActions(ctx context.Context, stop <-chan struct{}) { - switchModeTicker := time.NewTicker(rc.cfg.Cron.SwitchMode.Duration) logProgressTicker := time.NewTicker(rc.cfg.Cron.LogProgress.Duration) - defer func() { - switchModeTicker.Stop() - logProgressTicker.Stop() - }() + defer logProgressTicker.Stop() + + var switchModeChan <-chan time.Time + // tide backend don't need to switch tikv to import mode + if rc.cfg.TikvImporter.Backend != config.BackendTiDB { + switchModeTicker := time.NewTicker(rc.cfg.Cron.SwitchMode.Duration) + defer switchModeTicker.Stop() + switchModeChan = switchModeTicker.C - rc.switchToImportMode(ctx) + rc.switchToImportMode(ctx) + } else { + switchModeChan = make(chan time.Time) + } start := time.Now() @@ -481,7 +487,7 @@ func (rc *RestoreController) runPeriodicActions(ctx context.Context, stop <-chan log.L().Info("everything imported, stopping periodic actions") return - case <-switchModeTicker.C: + case <-switchModeChan: // periodically switch to import mode, as requested by TiKV 3.0 rc.switchToImportMode(ctx)