Skip to content
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.

restore: don't switch mode in tidb backend #368

Merged
merged 3 commits into from
Aug 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions lightning/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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)

Expand Down