SIGTERM is not terminating borgmatic #516

Closed
opened 5 months ago by NED567 · 3 comments

What I'm trying to do and why

I am using borgmatic on debian/testing. There borgmatic is started by a systemd timer and service. Stopping or restarting the service while borgmatic is creating an archive doesn't work.

Steps to reproduce (if a bug)

  • Create multiple configuration files in /etc/borgmatic.d/
    (it looks like it can also be 1 configuration file with multiple repositories)
  • Start /usr/bin/borgmatic --verbosity 1
  • While borgmatic is working (prune/create/...) on the first repository, stop it from an other terminal with pkill --signal TERM borgmatic.

Actual behavior (if a bug)

The work on the first repository is stopped, but borgmatic continues on the next repository.

Expected behavior (if a bug)

borgmatic should stop the current running action (of borg) and then terminate.

Other notes / implementation ideas

The signal SIGTERM indicates for a process that it needs to be stopped. The process is allowed to clean up it's environment (release locks) but then should stop as soon as possible. It should not start new long lasting actions.

It looks like the method _handle_signal only propagates the SIGTERM to the subprocesses, but the current process (borgmatic) can just continue (with the next repository). This is not correct. Borgmatic should stop as well.

Environment

borgmatic version: [1.5.20]

borgmatic installation method: [Debian package]

Borg version: [borg 1.2.0]

Python version: [Python 3.9.12]

Database version (if applicable): [N/A]

operating system and version: [debian testing]

#### What I'm trying to do and why I am using borgmatic on debian/testing. There borgmatic is started by a systemd timer and service. Stopping or restarting the service while borgmatic is creating an archive doesn't work. #### Steps to reproduce (if a bug) * Create multiple configuration files in /etc/borgmatic.d/ (it looks like it can also be 1 configuration file with multiple repositories) * Start `/usr/bin/borgmatic --verbosity 1` * While borgmatic is working (prune/create/...) on the first repository, stop it from an other terminal with `pkill --signal TERM borgmatic`. #### Actual behavior (if a bug) The work on the first repository is stopped, but borgmatic continues on the next repository. #### Expected behavior (if a bug) borgmatic should stop the current running action (of borg) and then terminate. #### Other notes / implementation ideas The signal SIGTERM indicates for a process that it needs to be stopped. The process is allowed to clean up it's environment (release locks) but then should stop as soon as possible. It should not start new long lasting actions. It looks like the method `_handle_signal` only propagates the SIGTERM to the subprocesses, but the current process (borgmatic) can just continue (with the next repository). This is not correct. Borgmatic should stop as well. #### Environment **borgmatic version:** [1.5.20] **borgmatic installation method:** [Debian package] **Borg version:** [borg 1.2.0] **Python version:** [Python 3.9.12] **Database version (if applicable):** [N/A] **operating system and version:** [debian testing]
Owner

Good catch! Looks like it's indeed a bug based on the code, although I haven't yet verified with a local repro. Thank you for filing this.

EDIT: Got a local repro now.

Good catch! Looks like it's indeed a bug based on the code, although I haven't yet verified with a local repro. Thank you for filing this. EDIT: Got a local repro now.
witten added the
bug
label 5 months ago
Owner

This has been fixed in master! It'll be part of the next release. Thanks again.

This has been fixed in master! It'll be part of the next release. Thanks again.
witten closed this issue 5 months ago
Owner

Released in borgmatic 1.6.0!

Released in borgmatic 1.6.0!
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#516
Loading…
There is no content yet.