Skip to content

Commit

Permalink
Fix the problem that backup time may be negative (pingcap#405)
Browse files Browse the repository at this point in the history
* backup: make sure backup time greater than 0

* backup: rename some variables

* backup: make CI happy
  • Loading branch information
YuJuncen authored and Hillium committed Jul 15, 2020
1 parent 36c3204 commit 6f32f09
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/backup/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,13 +406,14 @@ func (bc *Client) BackupRanges(
allFilesCollected := make(chan struct{}, 1)
go func() {
init := time.Now()
start, cur := init, init
// nolint:ineffassign
lastBackupStart, currentBackupStart := init, init
for files := range filesCh {
cur, start = start, time.Now()
lastBackupStart, currentBackupStart = currentBackupStart, time.Now()
allFiles = append(allFiles, files...)
summary.CollectSuccessUnit("backup ranges", 1, cur.Sub(start))
summary.CollectSuccessUnit("backup ranges", 1, currentBackupStart.Sub(lastBackupStart))
}
log.Info("Backup Ranges", zap.Duration("take", cur.Sub(init)))
log.Info("Backup Ranges", zap.Duration("take", currentBackupStart.Sub(init)))
allFilesCollected <- struct{}{}
}()

Expand Down

0 comments on commit 6f32f09

Please sign in to comment.