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

APPS-1417 Respect scheduled full backup timing #291

Open
wants to merge 10 commits into
base: v2
Choose a base branch
from

Conversation

korotkov-aerospike
Copy link
Contributor

No description provided.

@codecov-commenter
Copy link

codecov-commenter commented Dec 24, 2024

Codecov Report

Attention: Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.

Project coverage is 43.92%. Comparing base (49b9e8e) to head (bf22cba).

Files with missing lines Patch % Lines
pkg/service/config_applier.go 0.00% 3 Missing ⚠️
pkg/dto/current_backup.go 0.00% 2 Missing ⚠️
pkg/service/metrics.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##               v2     #291      +/-   ##
==========================================
- Coverage   43.95%   43.92%   -0.04%     
==========================================
  Files          52       52              
  Lines        2855     2857       +2     
==========================================
  Hits         1255     1255              
- Misses       1474     1476       +2     
  Partials      126      126              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@korotkov-aerospike
Copy link
Contributor Author

In scheduleFullBackup I removed running backup now.
Also, extracted interface for *BackupRoutineHandler and with it was able to add unit tests.
2 minor bugs found

  1. We should not add incremental backups to jobStore
  2. We should clean jobStore on config reload. jobStore should not be global variable in the first place, but it's too much of a change to fix it now.

Also, I added last run to CurrentBackup stats.

@korotkov-aerospike korotkov-aerospike marked this pull request as ready for review December 24, 2024 14:17
return r.Full == nil
}

func (r *LastBackupRun) LastAnyRun() *time.Time {
Copy link
Member

Choose a reason for hiding this comment

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

Consider renaming to LatestRun.

Copy link
Member

Choose a reason for hiding this comment

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

last_backup_run.go

@@ -158,7 +172,7 @@ func (h *BackupRoutineHandler) runFullBackupInternal(ctx context.Context, now ti
return err
}

h.lastRun.full = now
h.lastRun.Full = &now
Copy link
Member

Choose a reason for hiding this comment

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

It is not a new thing, but it is better to synchronize writes and reads to prevent data races.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No backup of the same type for the same routine will run simultaneously, no need for lock

Copy link
Member

Choose a reason for hiding this comment

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

There are two jobs scheduled for the full and incremental backup that may concurrently access those variables.

@@ -328,7 +342,7 @@ func (h *BackupRoutineHandler) runIncrementalBackupInternal(ctx context.Context,
return err
}

h.lastRun.incremental = now
h.lastRun.Incremental = &now
Copy link
Member

Choose a reason for hiding this comment

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

Consider synchronizing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No backup of the same type for the same routine will run simultaneously, no need for lock

@@ -10,6 +10,8 @@ type CurrentBackups struct {
Full *RunningJob
// Incremental represents the state of an incremental backup. Nil if no incremental backup is running.
Incremental *RunningJob
// LastRunTime: the last time when a backup was run
Copy link
Member

Choose a reason for hiding this comment

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

LastRunTime contains information about the latest run time for both full and incremental backups.

Incremental *time.Time
}

func NewLastRun(lastFullBackup *time.Time, lastIncrBackup *time.Time) LastBackupRun {
Copy link
Member

Choose a reason for hiding this comment

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

Consider renaming to MakeLastBackupRun or CreateLastBackupRun, since it is not a good practice to return a value for New constructors.

@reugn reugn changed the title APPS-1417 Only start backup on timer APPS-1417 Respect scheduled full backup timing Dec 24, 2024
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.

3 participants