Skip to content

Commit

Permalink
FMWK-570-backup-restore-state
Browse files Browse the repository at this point in the history
- fix ordinary file limit backup
  • Loading branch information
filkeith committed Oct 20, 2024
1 parent b825da9 commit f43e4e4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
7 changes: 4 additions & 3 deletions cmd/internal/flags/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,10 @@ func (f *Backup) NewFlagSet() *pflag.FlagSet {
"that was generated from the interrupted/failed run.")
flagSet.StringVar(&f.StateFileDst, "state-file-dst",
"",
"Name or path relatively to --directory where state file will be saved.\n"+
"Works only with --file-limit parameter. As we reach file-limit and save file to storage\n"+
"current state will be saved.")
"Name of a state file that will be saved in backup --directory.\n"+
"Works only with --file-limit parameter. As we reach --file-limit and close file,\n"+
"current state will be saved. Works only for default and/or partition backup. \n"+
"Not work with --parallel-nodes or --node--list.")
flagSet.Int64Var(&f.ScanPageSize, "scan-page-size",
10000,
"How many records will be read on one iteration for continuation backup.\n"+
Expand Down
10 changes: 5 additions & 5 deletions config_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ type BackupConfig struct {
Compact bool
// Only include records that have no ttl set (persistent records).
NoTTLOnly bool
// Either a path with a file name or a directory in which the backup state file will be
// placed if the backup is interrupted/fails. If a path with a file name is used, that
// exact path is where the backup file will be placed. If a directory is given, the backup
// state will be placed in the directory with name `<namespace>.asb.state`
// Works only for default and/or partition backup. Not work with ParallelNodes or NodeList.
// Name of a state file that will be saved in backup directory.
// Works only with FileLimit parameter.
// As we reach FileLimit and close file, the current state will be saved.
// Works only for default and/or partition backup.
// Not work with ParallelNodes or NodeList.
StateFile string
// Resumes an interrupted/failed backup from where it was left off, given the .state file
// that was generated from the interrupted/failed run.
Expand Down
7 changes: 6 additions & 1 deletion handler_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,12 @@ func closeWriters(backupWriters []io.WriteCloser, logger *slog.Logger) {
// configuration.
func (bh *BackupHandler) newWriter(ctx context.Context, n int) (io.WriteCloser, error) {
if bh.config.FileLimit > 0 {
return sized.NewWriter(ctx, n, bh.state.SaveCommandChan, bh.config.FileLimit, bh.newConfiguredWriter)
// For saving state operation, we init writer with a communication channel.
if bh.config.isStateFirstRun() || bh.config.isStateContinue() {
return sized.NewWriter(ctx, n, bh.state.SaveCommandChan, bh.config.FileLimit, bh.newConfiguredWriter)
}

return sized.NewWriter(ctx, n, nil, bh.config.FileLimit, bh.newConfiguredWriter)
}

return bh.newConfiguredWriter(ctx)
Expand Down

0 comments on commit f43e4e4

Please sign in to comment.