[pbs-devel] [PATCH proxmox-backup 08/11] datastore: add manifest locking
Fabian Grünbichler
f.gruenbichler at proxmox.com
Thu Oct 15 09:04:00 CEST 2020
On October 15, 2020 7:25 am, Dietmar Maurer wrote:
> AFAIR flock with atomically replaced files has problems/races.
>
> Unfortunately, I do not remember why. Somebody remember why? Or is it really safe?
you can obtain the flock a second time after replacing the original
(still locked) file. using a separate lock file that is not touched
other than for flocking solves this problem.
$ flock --verbose testfile -c 'sleep 60'
flock: getting lock took 0.000003 seconds
flock: executing /bin/zsh
while that is running and holding the lock:
$ flock --verbose --wait 5 testfile -c 'sleep 60'
flock: timeout while waiting to get lock
$ mv testfile2 testfile
$ flock --verbose --wait 5 testfile -c 'sleep 60'
flock: getting lock took 0.000003 seconds
flock: executing /bin/zsh
More information about the pbs-devel
mailing list