From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id BEC9F1FF09D for ; Sun, 01 Nov 2026 23:59:48 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id D84B42171D; Sun, 01 Nov 2026 23:59:14 +0100 (CET) From: Thomas Lamprecht To: pve-devel@lists.proxmox.com Subject: [PATCH manager 07/19] vzdump: stop all running backup jobs of the node Date: Sun, 1 Nov 2026 23:58:34 +0100 Message-ID: <20261101225849.884587-8-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261101225849.884587-1-t.lamprecht@proxmox.com> References: <20261101225849.884587-1-t.lamprecht@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1793573948250 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.396 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: AJVSE63CK7ECIPFRNYV4XOA7K4U4OLXJ X-Message-ID-Hash: AJVSE63CK7ECIPFRNYV4XOA7K4U4OLXJ X-MailFrom: t.lamprecht@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- PVE/VZDump.pm | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm index d07ced61b..a9a2256a8 100644 --- a/PVE/VZDump.pm +++ b/PVE/VZDump.pm @@ -44,7 +44,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(); @@ -811,8 +810,6 @@ sub getlock { debugmsg('info', "got global lock", undef, 1); } - PVE::Tools::file_set_contents($pidfile, $upid); - return $SERVER_FLCK; } @@ -1500,8 +1497,6 @@ sub exec_backup { die $err if $err; die "job errors\n" if $errcount; - - unlink $pidfile; } sub option_exists { @@ -1566,26 +1561,26 @@ 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::Tools::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); } + die "stopping backup process " . join(', ', map { $_->{pid} } $running->@*) . " failed\n"; } sub get_included_guests { -- 2.47.3