We currently have a 5 seconds timeout for zfs_request for non-workers and
that is too low for some use cases of pvesr. As a workaround we create
fake workers doing the storage operations and use our own timeouts.

Signed-off-by: Fabian Ebner <f.eb...@proxmox.com>
---

Is 60 a good value for the timeout?
Should we make the timeout configurable via the replication config?

 PVE/CLI/pvesr.pm | 32 +++++++++++++++++++++++---------
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/PVE/CLI/pvesr.pm b/PVE/CLI/pvesr.pm
index cb79e2bf..95550860 100644
--- a/PVE/CLI/pvesr.pm
+++ b/PVE/CLI/pvesr.pm
@@ -136,14 +136,22 @@ __PACKAGE__->register_method ({
            my $images = $plugin->list_images($storeid, $scfg, $vmid, undef, 
$cache);
            push @$volids, map { $_->{volid} } @$images;
        }
-       my ($last_snapshots, $cleaned_replicated_volumes) = 
PVE::Replication::prepare($storecfg, $volids, $jobid, $last_sync, 
$parent_snapname, $logfunc);
-       foreach my $volid (keys %$cleaned_replicated_volumes) {
-           if (!$wanted_volids->{$volid}) {
-               $logfunc->("$jobid: delete stale volume '$volid'");
-               PVE::Storage::vdisk_free($storecfg, $volid);
-               delete $last_snapshots->{$volid};
+
+       # FIXME: We currently manually set the worker flag here to avoid
+       # low I/O timeouts. This should be replaced by a lightweight worker
+       # once we have those.
+       my $last_snapshots = PVE::Tools::run_fork_with_timeout(60, sub {
+           PVE::RPCEnvironment->set_worker_flag(1);
+           my ($last_snapshots, $cleaned_replicated_volumes) = 
PVE::Replication::prepare($storecfg, $volids, $jobid, $last_sync, 
$parent_snapname, $logfunc);
+           foreach my $volid (keys %$cleaned_replicated_volumes) {
+               if (!$wanted_volids->{$volid}) {
+                   $logfunc->("$jobid: delete stale volume '$volid'");
+                   PVE::Storage::vdisk_free($storecfg, $volid);
+                   delete $last_snapshots->{$volid};
+               }
            }
-       }
+           return $last_snapshots;
+       });
 
        print to_json($last_snapshots) . "\n";
 
@@ -200,8 +208,14 @@ __PACKAGE__->register_method ({
            print STDERR "$msg\n";
        };
 
-       my $last_snapshots = PVE::Replication::prepare(
-           $storecfg, $volids, $jobid, $last_sync, undef, $logfunc);
+       # FIXME: We currently manually set the worker flag here to avoid
+       # low I/O timeouts. This should be replaced by a lightweight worker
+       # once we have those.
+       PVE::Tools::run_fork_with_timeout(60, sub {
+           PVE::RPCEnvironment->set_worker_flag(1);
+           my $last_snapshots = PVE::Replication::prepare(
+               $storecfg, $volids, $jobid, $last_sync, undef, $logfunc);
+       });
 
        return undef;
     }});
-- 
2.20.1


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to