[pbs-devel] [PATCH proxmox-backup 4/5] backup: use flock on backup group to forbid multiple backups at once

Dietmar Maurer dietmar at proxmox.com
Thu Jul 30 09:41:22 CEST 2020


> On 07/30/2020 9:36 AM Stefan Reiter <s.reiter at proxmox.com> wrote:
> 
>  
> On 7/30/20 7:50 AM, Dietmar Maurer wrote:
> >> +        // acquire in non-blocking mode, no point in waiting here since other
> >> +        // backups could still take a very long time
> >> +        tools::lock_file(&mut handle, true, Some(Duration::from_nanos(0)))
> >> +            .map_err(|err| {
> >> +                match err.downcast_ref::<nix::Error>() {
> >> +                    Some(nix::Error::Sys(nix::errno::Errno::EAGAIN)) => {
> > 
> > Honestly, I would remove this special case with downcast - the default error message is good enough. Isn't it?
> > 
> 
> The original message ends in "EAGAIN - Try again", which to me sounded 
> like inviting the user to just run the command again, instead of telling 
> them there's a backup running.

The suggestion is too use: "unable to acquire lock on backup group {:?} - {}",

> 
> >> +                        return format_err!(
> >> +                            "unable to acquire lock on backup group {:?} - another backup is already running",
> >> +                            self.group_path(),
> >> +                        );
> >> +                    },
> >> +                    _ => ()
> >> +                }
> >> +                format_err!(
> >> +                    "unable to acquire lock on backup group {:?} - {}",
> >> +                    self.group_path(),
> >> +                    err,
> >> +                )
> >> +            })?;
> >> +
> >> +        Ok(handle)
> >> +    }
> >> +





More information about the pbs-devel mailing list