diff --git a/pkg/backup/watch.go b/pkg/backup/watch.go index d616af86..d1bc9b19 100644 --- a/pkg/backup/watch.go +++ b/pkg/backup/watch.go @@ -115,7 +115,11 @@ func (b *Backuper) Watch(watchInterval, fullInterval, watchBackupNameTemplate, t b.log.Infof("Time before do full backup %v", timeBeforeDoFullBackup) if timeBeforeDoBackup > 0 && timeBeforeDoFullBackup > 0 { b.log.Infof("Waiting %d seconds until continue doing backups due watch interval", timeBeforeDoBackup) - time.Sleep(b.cfg.General.WatchDuration - now.Sub(lastBackup)) + select { + case <-ctx.Done(): + return ctx.Err() + case <-time.After(b.cfg.General.WatchDuration - now.Sub(lastBackup)): + } } now = time.Now() lastBackup = now diff --git a/test/integration/integration_test.go b/test/integration/integration_test.go index d8baa094..78e5f54a 100644 --- a/test/integration/integration_test.go +++ b/test/integration/integration_test.go @@ -785,7 +785,7 @@ func testAPIWatchAndKill(r *require.Assertions, ch *TestClickHouse) { r.NoError(err) time.Sleep(7 * time.Second) - checkWatchBackup(2) + checkWatchBackup(1) runKillCommand("watch") checkCanceledCommand(2) }