From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH manager 09/19] vzdump: run job-init hook and set up target once the job may start
Date: Sun, 1 Nov 2026 23:58:36 +0100 [thread overview]
Message-ID: <20261101225849.884587-10-t.lamprecht@proxmox.com> (raw)
In-Reply-To: <20261101225849.884587-1-t.lamprecht@proxmox.com>
The job-init hook and the activation of the backup storage ran before
taking the global lock. A job waiting for another one thus already
called its hook script, for example to mount or wake up its target,
while the other job was still running, and then possibly waited for
hours.
Take the lock first and do the job setup afterwards, handling setup
errors like a failure to get the lock. Hook scripts now see the job
phases of different jobs strictly in sequence.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
PVE/API2/VZDump.pm | 4 +++-
PVE/VZDump.pm | 20 ++++++++++++--------
test/vzdump_new_test.pl | 1 +
3 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/PVE/API2/VZDump.pm b/PVE/API2/VZDump.pm
index c8b66169e..083b9ea35 100644
--- a/PVE/API2/VZDump.pm
+++ b/PVE/API2/VZDump.pm
@@ -137,7 +137,9 @@ __PACKAGE__->register_method({
my $vzdump = PVE::VZDump->new($cmdline, $param, $skiplist);
my $LOCK_FH = eval {
- $vzdump->getlock($upid); # only one process allowed
+ my $lock_fh = $vzdump->getlock($upid); # only one process allowed
+ $vzdump->init_job();
+ $lock_fh;
};
if (my $err = $@) {
chomp($err); # otherwise reported as multiple problems
diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index a9a2256a8..a86be4f09 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -674,6 +674,16 @@ sub new {
delete $opts->{$_} for qw(notes-template protected);
}
+ $self->{'default-prune-backups'} = $defaults->{'prune-backups'};
+
+ return $self;
+}
+
+sub init_job {
+ my ($self) = @_;
+
+ my $opts = $self->{opts};
+
my $errors = '';
my $add_error = sub {
my ($error) = @_;
@@ -714,7 +724,7 @@ sub new {
die "internal error";
}
- $opts->{'prune-backups'} //= $defaults->{'prune-backups'};
+ $opts->{'prune-backups'} //= $self->{'default-prune-backups'};
# avoid triggering any remove code path if keep-all is set
$opts->{remove} = 0 if $opts->{'prune-backups'}->{'keep-all'};
@@ -723,13 +733,7 @@ sub new {
$add_error->("tmpdir '$opts->{tmpdir}' does not exist");
}
- if ($errors) {
- eval { $self->send_notification([], 0, $errors); };
- debugmsg('err', $@) if $@;
- die "$errors\n";
- }
-
- return $self;
+ die "$errors\n" if $errors;
}
sub get_mount_info {
diff --git a/test/vzdump_new_test.pl b/test/vzdump_new_test.pl
index db829e70f..490ae4482 100755
--- a/test/vzdump_new_test.pl
+++ b/test/vzdump_new_test.pl
@@ -539,6 +539,7 @@ foreach my $test (@tests) {
PVE::VZDump::parse_mailto_exclude_path($test->{cli_param});
my $vzdump = PVE::VZDump->new('fake cmdline', $test->{cli_param}, undef);
+ $vzdump->init_job();
my $opts = $vzdump->{opts} or die "did not get options\n";
--
2.47.3
next prev parent reply other threads:[~2026-11-01 22:59 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-01 22:58 [PATCH cluster,storage,guest-common,container,manager,docs 00/19] parallel guest backups and backup concurrency limits Thomas Lamprecht
2026-11-01 22:58 ` [PATCH cluster 01/19] datacenter config: add backup concurrency setting Thomas Lamprecht
2026-11-01 22:58 ` [PATCH cluster 02/19] datacenter config: backup concurrency: add cluster-wide limit Thomas Lamprecht
2026-11-01 22:58 ` [PATCH storage 03/19] add backup concurrency option to storages Thomas Lamprecht
2026-11-01 22:58 ` [PATCH guest-common 04/19] vzdump: add options for parallel guest backups and overlapping jobs Thomas Lamprecht
2026-11-01 22:58 ` [PATCH container 05/19] vzdump: honor bandwidth limit for backups to Proxmox Backup Server Thomas Lamprecht
2026-11-01 22:58 ` [PATCH manager 06/19] vzdump: notification: capture guest logs right after each backup Thomas Lamprecht
2026-11-01 22:58 ` [PATCH manager 07/19] vzdump: stop all running backup jobs of the node Thomas Lamprecht
2026-11-01 22:58 ` [PATCH manager 08/19] vzdump: show the error if a job could not get the global lock Thomas Lamprecht
2026-11-01 22:58 ` Thomas Lamprecht [this message]
2026-11-01 22:58 ` [PATCH manager 10/19] vzdump: list guests as skipped if the job could not start Thomas Lamprecht
2026-11-01 22:58 ` [PATCH manager 11/19] vzdump: back up guests of a job in parallel Thomas Lamprecht
2026-11-01 22:58 ` [PATCH manager 12/19] vzdump: allow jobs to run alongside each other Thomas Lamprecht
2026-11-01 22:58 ` [PATCH manager 13/19] ui: options: add backup concurrency for datacenter and nodes Thomas Lamprecht
2026-11-01 22:58 ` [PATCH manager 14/19] ui: backup job: add concurrency and overlap options Thomas Lamprecht
2026-11-01 22:58 ` [PATCH manager 15/19] vzdump: limit concurrent guest backups cluster-wide Thomas Lamprecht
2026-11-01 22:58 ` [PATCH manager 16/19] vzdump: honor backup concurrency limits of storages Thomas Lamprecht
2026-11-01 22:58 ` [PATCH manager 17/19] api: backup info: add endpoints for cluster-wide backup slots Thomas Lamprecht
2026-11-01 22:58 ` [PATCH manager 18/19] ui: add cluster-wide and storage backup concurrency limits Thomas Lamprecht
2026-11-01 22:58 ` [PATCH docs 19/19] 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=20261101225849.884587-10-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox