Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watch interval validation fix #569

Merged
merged 1 commit into from
Dec 19, 2022

Conversation

clamoris
Copy link
Contributor

Current validation prevents from properly using watch functionality as it requires a wrong number of stored backups to work.

Example:
1h watch interval, 5h full interval needs at least 5 stored remote backups to work, but validation only accepts 4 or less.

@clamoris
Copy link
Contributor Author

clamoris commented Nov 24, 2022

On the side note --watch-backup-name-template seems to have some problems too.

Pattern "ch_{replica}-{type}-{time:20060102150405}" results in default shard01-full-20221124155826 name. replica is a macros.

@@ -53,7 +53,7 @@ func (b *Backuper) ValidateWatchParams(watchInterval, fullInterval, watchBackupN
if watchBackupNameTemplate != "" {
b.cfg.General.WatchBackupNameTemplate = watchBackupNameTemplate
}
if b.cfg.General.FullDuration.Seconds() < b.cfg.General.WatchDuration.Seconds()*float64(b.cfg.General.BackupsToKeepRemote) {
if b.cfg.General.FullDuration.Seconds() > b.cfg.General.WatchDuration.Seconds()*float64(b.cfg.General.BackupsToKeepRemote) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure this will help resolve your "connection close" issue?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't understand what exactly you try to fix
this part of code is not related to current validation allow backups_to_keep_remote less than 4

could you provide more examples in comments?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

Current (wrong) version in pseudo-code:

If FullDurationSeconds < (BackupsToKeep * WatchInterval) {
    raise validation error
}

It prevents user from increasing amount of backups - if we set BackupsToKeep to infinity validation starts failing.

Example:
Let say we want to make incremental daily backups and have full backup on Sunday and to store two weeks of backups on remote.

FullDurationSeconds = 1 week (604800 seconds)
BackupsToKeep = 14
WatchInterval = 1 day (86400 seconds)

Validation will fail, since 604800 < (14 * 86400), it would only work if BackupsToKeep is less than 7, which is not enough to store a full week. With the changes it will accept any value of BackupsToKeep larger than 7.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. got it
could you fix intergration_test.go for https://github.com/AlexAkulov/clickhouse-backup/actions/runs/3541456947/jobs/5949819982#step:7:56324

look like your changes broke some backup API scenarios

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@clamoris any progress?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests on my machine are ridiculously slow, something is not right
Screenshot 2022-12-02 at 21 52 45

@Slach
Copy link
Collaborator

Slach commented Nov 24, 2022

oops sorry, miss you with author of #568

@@ -53,7 +53,7 @@ func (b *Backuper) ValidateWatchParams(watchInterval, fullInterval, watchBackupN
if watchBackupNameTemplate != "" {
b.cfg.General.WatchBackupNameTemplate = watchBackupNameTemplate
}
if b.cfg.General.FullDuration.Seconds() < b.cfg.General.WatchDuration.Seconds()*float64(b.cfg.General.BackupsToKeepRemote) {
if b.cfg.General.FullDuration.Seconds() > b.cfg.General.WatchDuration.Seconds()*float64(b.cfg.General.BackupsToKeepRemote) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't understand what exactly you try to fix
this part of code is not related to current validation allow backups_to_keep_remote less than 4

could you provide more examples in comments?

@Slach Slach merged commit 5ba48a5 into Altinity:master Dec 19, 2022
@Slach Slach mentioned this pull request Dec 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants