all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH v2 manager 07/20] vzdump: stop all running backup jobs of the node
Date: Wed, 18 Nov 2026 14:18:31 +0100	[thread overview]
Message-ID: <20261118132947.1093069-8-t.lamprecht@proxmox.com> (raw)
In-Reply-To: <20261118132947.1093069-1-t.lamprecht@proxmox.com>

Stopping running backups only signalled the job recorded in the pid
file, which is the one holding the global lock. Jobs waiting for the
lock went on afterwards, and once jobs can run alongside each other,
the pid file cannot represent all of them anyway.

Signal every backup task of the node instead, including those still
waiting to start, and drop the pid file. As when stopping a task, the
signal goes to the whole process group.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
---

changes v1 -> v2:
- use PVE::UPID, say "processes" if several are left [Fiona]

 PVE/VZDump.pm | 39 ++++++++++++++++++---------------------
 1 file changed, 18 insertions(+), 21 deletions(-)

diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index 92a48babf..9842069a7 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -22,6 +22,7 @@ use PVE::JSONSchema qw(get_standard_option);
 use PVE::Notify;
 use PVE::RPCEnvironment;
 use PVE::Storage;
+use PVE::UPID;
 use PVE::VZDump::Common;
 use PVE::VZDump::Plugin;
 use PVE::Tools qw(extract_param split_list);
@@ -44,7 +45,6 @@ PVE::JSONSchema::register_standard_option(
 my @posix_filesystems = qw(ext3 ext4 nfs nfs4 reiserfs xfs);
 
 my $lockfile = '/var/run/vzdump.lock';
-my $pidfile = '/var/run/vzdump.pid';
 my $logdir = '/var/log/vzdump';
 
 my @plugins = qw();
@@ -816,8 +816,6 @@ sub getlock {
         debugmsg('info', "got global lock", undef, 1);
     }
 
-    PVE::Tools::file_set_contents($pidfile, $upid);
-
     return $SERVER_FLCK;
 }
 
@@ -1515,8 +1513,6 @@ sub exec_backup {
     die $err if $err;
 
     die "job errors\n" if $errcount;
-
-    unlink $pidfile;
 }
 
 sub option_exists {
@@ -1581,26 +1577,27 @@ sub verify_vzdump_parameters {
 }
 
 sub stop_running_backups {
-    my ($self) = @_;
+    my $nodename = PVE::INotify::nodename();
 
-    my $upid = PVE::Tools::file_read_firstline($pidfile);
-    return if !$upid;
+    my $running = [];
+    for my $worker (PVE::RPCEnvironment::get()->active_workers()->@*) {
+        my $task = PVE::UPID::decode($worker->{upid}, 1) or next;
+        next if $task->{type} ne 'vzdump' || $task->{node} ne $nodename;
+        next if !PVE::ProcFSTools::check_process_running($task->{pid}, $task->{pstart});
 
-    my $task = PVE::Tools::upid_decode($upid);
+        # the whole process group, like stopping the task does
+        kill(15, -$task->{pid});
+        push $running->@*, $task;
+    }
 
-    if (
-        PVE::ProcFSTools::check_process_running($task->{pid}, $task->{pstart})
-        && PVE::ProcFSTools::read_proc_starttime($task->{pid}) == $task->{pstart}
-    ) {
-        kill(15, $task->{pid});
-        # wait max 15 seconds to shut down (else, do nothing for now)
-        my $i;
-        for ($i = 15; $i > 0; $i--) {
-            last if !PVE::ProcFSTools::check_process_running(($task->{pid}, $task->{pstart}));
-            sleep(1);
-        }
-        die "stopping backup process $task->{pid} failed\n" if $i == 0;
+    for (1 .. 15) {
+        $running = [grep { PVE::ProcFSTools::check_process_running($_->{pid}, $_->{pstart}) }
+            $running->@*];
+        return if !scalar($running->@*);
+        sleep(1);
     }
+    my $what = scalar($running->@*) > 1 ? 'processes' : 'process';
+    die "stopping backup $what " . join(', ', map { $_->{pid} } $running->@*) . " failed\n";
 }
 
 sub get_included_guests {
-- 
2.47.3





  parent reply	other threads:[~2026-11-18 13:30 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 13:18 [PATCH v2 cluster,storage,guest-common,manager,docs 00/20] parallel guest backups and backup concurrency limits Thomas Lamprecht
2026-11-18 13:18 ` [PATCH v2 cluster 01/20] datacenter config: add backup concurrency setting Thomas Lamprecht
2026-11-18 13:18 ` [PATCH v2 cluster 02/20] datacenter config: backup concurrency: add cluster-wide limit Thomas Lamprecht
2026-11-18 13:18 ` [PATCH v2 storage 03/20] add backup concurrency option to storages Thomas Lamprecht
2026-11-18 13:18 ` [PATCH v2 guest-common 04/20] vzdump: add options for parallel guest backups and overlapping jobs Thomas Lamprecht
2026-11-18 13:18 ` [PATCH v2 manager 05/20] vzdump: drop never-set fallback for the lock wait time Thomas Lamprecht
2026-11-18 13:18 ` [PATCH v2 manager 06/20] vzdump: notification: capture guest logs right after each backup Thomas Lamprecht
2026-11-18 13:18 ` Thomas Lamprecht [this message]
2026-11-18 13:18 ` [PATCH v2 manager 08/20] vzdump: show the error if a job could not get the global lock Thomas Lamprecht
2026-11-18 13:18 ` [PATCH v2 manager 09/20] vzdump: run job-init hook and set up target once the job may start Thomas Lamprecht
2026-11-18 13:18 ` [PATCH v2 manager 10/20] vzdump: list guests as skipped if the job could not start Thomas Lamprecht
2026-11-18 13:18 ` [PATCH v2 manager 11/20] vzdump: back up guests of a job in parallel Thomas Lamprecht
2026-11-18 13:18 ` [PATCH v2 manager 12/20] vzdump: allow jobs to run alongside each other Thomas Lamprecht
2026-11-18 13:18 ` [PATCH v2 manager 13/20] ui: options: add backup concurrency for datacenter and nodes Thomas Lamprecht
2026-11-18 13:18 ` [PATCH v2 manager 14/20] ui: backup job: add concurrency and overlap options Thomas Lamprecht
2026-11-18 13:18 ` [PATCH v2 manager 15/20] ui: backup now: add overlap option Thomas Lamprecht
2026-11-18 13:18 ` [PATCH v2 manager 16/20] vzdump: limit concurrent guest backups cluster-wide Thomas Lamprecht
2026-11-18 13:18 ` [PATCH v2 manager 17/20] vzdump: honor backup concurrency limits of storages Thomas Lamprecht
2026-11-18 13:18 ` [PATCH v2 manager 18/20] api: backup info: add endpoints for cluster-wide backup slots Thomas Lamprecht
2026-11-18 13:18 ` [PATCH v2 manager 19/20] ui: add cluster-wide and storage backup concurrency limits Thomas Lamprecht
2026-11-18 13:18 ` [PATCH v2 docs 20/20] vzdump: document concurrent backups and their limits Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261118132947.1093069-8-t.lamprecht@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal