Skip to content

Rewrite PID files automatically for backup/restore

What does this MR do and why?

As part of !97218 (merged), we created a PID lock mechanism to detect if there is another backup and restore process in progress to avoid parallel execution.

As a follow-up, this MR improves the user experience by validating if the PID exists in the system against the PID file that was not removed due to unexpected termination signals.

If the PID file exists and the process is not running, we rewrite the PID file content using the current PID, so users can trigger backup/restore tasks without removing the PID file manually, which is no more than a leftover.

How to set up and validate locally

  1. cd ~/<to_your_rails_root_app>
  2. Execute echo "123456" > tmp/backup_restore.pid (validate that the pid 123456 does not exist with ps aux | grep 123456).
  3. Run a backup and restore rake task.
  4. Running another backup and restore task should fail while processing the previous task.
  5. Expect to see a "-- Deleting backup and restore lock file" message.
  6. The file tmp/backup_restore.pid should not exist.
  7. You should be able to run another backup and restore the rake task after that.

Note: To check if the PID file was rewritten correctly, you can comment on the File.delete operation and cat tmp/backup_restore.pid.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #408984 (closed)

Edited by Javiera Tapia

Merge request reports

Loading