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

Support config set backup-dir new-dir #1026

Merged
merged 9 commits into from
Oct 24, 2022

Conversation

mapleFU
Copy link
Member

@mapleFU mapleFU commented Oct 22, 2022

This fixes #1007

TODO:

  • Implement set backup-dir
  • Update backup_mu_ to make set dir more lightweight (may not complete in this patch)
  • Testing setting backup with gocase

@mapleFU
Copy link
Member Author

mapleFU commented Oct 22, 2022

@git-hulk in current implementions, a config set backup-dir ... might blocked by a backup or a purge. And the backup_mu_ is moved to Config. And the backup_creating_time_ will not be changed if config is changed, so it's still a bit trickey.

If we don't want blocked by a backup, backup_mu_ should have less critical sections, like:

config_set():
  grab backup_mu_
  set config
  reset backup_creating_time_ if storage_ != nullptr

backup():
  grab backup_mu_
  test backup_flag:
    return if backup_flag is True
  set backup_flag
  get config
  release backup_mu_
  
  do backup
   
  grab backup_mu_
  unset backup_flag
  if failed:
    return
  if config->backup-dir changed:
    return
  set backup_creating_time_

purge():
  grab backup_mu_
  test backup_flag and backup_creating_time_:
    return if backup_flag is True or backup_creating_time_ is not too old
  set backup_flag
  get config
  release backup_mu_

  pruge files

  grab backup_mu_
  unset backup_flag

@PragmaTwice
Copy link
Member

Hi @mapleFU, after a glance, I have two simple ideas:

  1. Could we add a new seperate mutex for directory changing? e.g. backup_mu and backup_dir_mu.
  2. If we use only one mutex backup_mu, could we use try_lock on the directory changing? e.g.
if(backup_mu.try_lock()) exchange ...
else report("backuping, cannot change...")

@mapleFU mapleFU changed the title [WIP] Support config set backup-dir new-dir Support config set backup-dir new-dir Oct 22, 2022
@mapleFU
Copy link
Member Author

mapleFU commented Oct 22, 2022

  1. Could we add a new seperate mutex for directory changing? e.g. backup_mu and backup_dir_mu.

It's ok, and it can solve part of the problem, but the syntax for backup_creating_time_ may still need to be specified.

  1. If we use only one mutex backup_mu, could we use try_lock on the directory changing? e.g.
if(backup_mu.try_lock()) exchange ...
else report("backuping, cannot change...")

Both ok for me, personally, I think using backup_dir_mu is better here, but when we increasing our changable variables, the state of our system would be chaos. Maybe report error is better here.

git-hulk
git-hulk previously approved these changes Oct 23, 2022
tanruixiang
tanruixiang previously approved these changes Oct 23, 2022
Copy link
Member

@tanruixiang tanruixiang left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you very much for your contribution.

@mapleFU mapleFU dismissed stale reviews from tanruixiang and git-hulk via c8e4f67 October 23, 2022 15:25
@mapleFU
Copy link
Member Author

mapleFU commented Oct 23, 2022

@git-hulk @PragmaTwice @tanruixiang update some comments, and the patch is ready to be merged now.

@git-hulk
Copy link
Member

Thanks all, merging...

@git-hulk git-hulk merged commit ce085aa into apache:unstable Oct 24, 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.

Support config 'backup-dir' can be changed
4 participants