Skip to content

Commit e46bceb

Browse files
committed
fix watch unexpected connection closed behavior, fix [568](Altinity#568)
Signed-off-by: Slach <bloodjazman@gmail.com>
1 parent 2d1bb5e commit e46bceb

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ BUG FIXES
1414
- `MaterializedPostgreSQL` doesn't support FREEZE, fix [550](https://github.com/AlexAkulov/clickhouse-backup/issues/550), see also https://github.com/ClickHouse/ClickHouse/issues/32902, https://github.com/ClickHouse/ClickHouse/issues/44252
1515
- `create` and `restore` commands will respect `skip_tables` config options and `--table` cli parameter, to avoid create unnecessary empty databases, fix [583](https://github.com/AlexAkulov/clickhouse-backup/issues/583)
1616
- fix `watch` unexpected connection closed behavior, fix [568](https://github.com/AlexAkulov/clickhouse-backup/issues/568)
17+
- fix `watch` validation parameters corner cases, close [569](https://github.com/AlexAkulov/clickhouse-backup/pull/569)
1718

1819
# v2.1.2
1920
IMPROVEMENTS

pkg/backup/watch.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ func (b *Backuper) ValidateWatchParams(watchInterval, fullInterval, watchBackupN
5353
if watchBackupNameTemplate != "" {
5454
b.cfg.General.WatchBackupNameTemplate = watchBackupNameTemplate
5555
}
56-
if b.cfg.General.FullDuration.Seconds() < b.cfg.General.WatchDuration.Seconds()*float64(b.cfg.General.BackupsToKeepRemote) {
57-
return fmt.Errorf("fullInterval `%s` is not enought to keep %d remote backups with watchInterval `%s`", b.cfg.General.FullInterval, b.cfg.General.BackupsToKeepRemote, b.cfg.General.WatchInterval)
56+
if b.cfg.General.BackupsToKeepRemote > 0 && b.cfg.General.WatchDuration.Seconds()*float64(b.cfg.General.BackupsToKeepRemote) < b.cfg.General.FullDuration.Seconds() {
57+
return fmt.Errorf("fullInterval `%s` is too long to keep %d remote backups with watchInterval `%s`", b.cfg.General.FullInterval, b.cfg.General.BackupsToKeepRemote, b.cfg.General.WatchInterval)
5858
}
5959
return nil
6060
}
@@ -87,12 +87,10 @@ func (b *Backuper) Watch(watchInterval, fullInterval, watchBackupNameTemplate, t
8787
var createRemoteErr error
8888
var deleteLocalErr error
8989
for {
90-
b.log.Warnf("SUKA!!! b.ch.IsOpen=%v", b.ch.IsOpen)
9190
if !b.ch.IsOpen {
9291
if err = b.ch.Connect(); err != nil {
9392
return err
9493
}
95-
b.log.Warnf("BLA!!! b.ch.IsOpen=%v", b.ch.IsOpen)
9694
}
9795
select {
9896
case <-ctx.Done():

0 commit comments

Comments
 (0)