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

Stefan Reiter s.reiter at proxmox.com
Thu Jul 30 10:02:56 CEST 2020


On 7/30/20 9:41 AM, Dietmar Maurer wrote:
> 
>> 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 {:?} - {}",
> 

Yes, and with that the error message reads:

"Error: unable to acquire lock on backup group "host/xyz" - EAGAIN: Try 
again"

...which I think might confuse some users.
>>
>>>> +                        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