digint / btrbk

Tool for creating snapshots and remote backups of btrfs subvolumes
https://digint.ch/btrbk/
GNU General Public License v3.0
1.6k stars 117 forks source link

btrbk lockfile created but never deleted #534

Closed zilexa closed 1 year ago

zilexa commented 1 year ago

btrbk command line client, version 0.32.6 On Manjaro Gnome, LTS kernel 6.1. I just noticed, with this in my conf:

lockfile                   /var/lock/btrbk.lock

The lockfile gets created (using run, not using dry-run). But it is not deleted after btrbk is finished. Also, I can run btrbk again, and it will simply run, ignoring the lockfile.

I think this is a little bug?

digint commented 1 year ago

Not a bug. Btrbk is using exclusive locking with flock(2). These locks are created/removed by the OS on the lockfile, while the file itself represents only a namespace. Deleting lockfiles can have side-effects, and some people like to place/remove locks outside of btrbk (which is why /var/lock is usually mounted as tmpfs).

Try:

flock /var/lock/testlock btrbk run --lockfile /var/lock/testlock

this should always exit with: "ERROR: Failed to take lock (another btrbk instance is running): /var/lock/testlock"

Also, I can run btrbk again, and it will simply run, ignoring the lockfile.

It's ignoring the presence of the lockfile, but not the locks held via flock

zilexa commented 1 year ago

Learned something new! Thanks :)