Discussion:
[rsnapshot-discuss] Stale lock file
Hervé Werner
2015-06-08 11:26:11 UTC
Permalink
Hello

I found out that in some cases rsnapshot's lockfile is not removed which makes it issue a warning the next time it runs.

Here is a demonstration :

I'm using the following configuration file :

config file :
config_version 1.2
snapshot_root /media/LV_BACKUP/rsnapshot/
cmd_cp /bin/cp
cmd_rm /bin/rm
cmd_rsync /usr/bin/rsync
cmd_logger /usr/bin/logger
retain alpha 3
retain beta 2
retain gamma 2
verbose 5
loglevel 3
lockfile /var/run/rsnapshot.pid
one_fs 1
link_dest 1
use_lazy_deletes 1
backup /tmp/test localhost


I then execute rsnapshot twice :

$ sudo rsnapshot alpha
require Lchown
Lchown module not found
Setting locale to POSIX "C"
echo 32014 > /var/run/rsnapshot.pid
mkdir -m 0755 -p /media/LV_BACKUP/rsnapshot/alpha.0/
/usr/bin/rsync -avx --delete --numeric-ids --relative --delete-excluded \
/tmp/test/ /media/LV_BACKUP/rsnapshot/alpha.0/localhost
sending incremental file list
created directory /media/LV_BACKUP/rsnapshot/alpha.0/localhost
/tmp/
/tmp/test/
/tmp/test/env.txt
/tmp/test/install-dep.txt
/tmp/test/install-dep.txt2

sent 38,800 bytes received 152 bytes 77,904.00 bytes/sec
total size is 38,490 speedup is 0.99
rsync succeeded
touch /media/LV_BACKUP/rsnapshot/alpha.0/
/usr/bin/logger -p user.info -t rsnapshot[32014] /usr/local/bin/rsnapshot \
alpha: completed successfully


$ sudo rsnapshot alpha
require Lchown
Lchown module not found
Setting locale to POSIX "C"
WARNING: Removing stale lockfile /var/run/rsnapshot.pid
/usr/bin/logger -p user.err -t rsnapshot[32020] WARNING: Removing stale \
lockfile /var/run/rsnapshot.pid
WARNING: About to remove lockfile /var/run/rsnapshot.pid which belongs to a different process: 32014 (this is OK if it's a stale lock)
rm -f /var/run/rsnapshot.pid
echo 32020 > /var/run/rsnapshot.pid
mv /media/LV_BACKUP/rsnapshot/alpha.0/ /media/LV_BACKUP/rsnapshot/alpha.1/
mkdir -m 0755 -p /media/LV_BACKUP/rsnapshot/alpha.0/
/usr/bin/rsync -avx --delete --numeric-ids --relative --delete-excluded \
--link-dest=/media/LV_BACKUP/rsnapshot/alpha.1/localhost \
/tmp/test/ /media/LV_BACKUP/rsnapshot/alpha.0/localhost
sending incremental file list
created directory /media/LV_BACKUP/rsnapshot/alpha.0/localhost

sent 171 bytes received 85 bytes 512.00 bytes/sec
total size is 38,490 speedup is 150.35
rsync succeeded
touch /media/LV_BACKUP/rsnapshot/alpha.0/
/usr/bin/logger -p user.err -t rsnapshot[32020] WARNING: \
/usr/local/bin/rsnapshot alpha: completed, but with some warnings


Actually according to the source code this behavioir happens when using the lazy_delete feature as the lockfile seem to only be removed when a _delete directory exists :

## code sub handle_interval

# if use_lazy_delete is on, delete the _delete.$$ directory
# we just check for the directory, it will have been created or not depending on the value of use_lazy_delete
if (-d "$config_vars{'snapshot_root'}/_delete.$$") {

# this is the last thing to do here, and it can take quite a while.
# we remove the lockfile here since this delete shouldn't block other rsnapshot jobs from running
remove_lockfile();


So I think rsnapshot should either create a dumb _delete directory if there is no previous backup to clean or add something like remove_lockfile() if ($use_lazy_deletes).


dud
Benedikt Heine
2015-06-09 09:40:34 UTC
Permalink
On June 8, 2015 1:26:11 PM CEST, "Hervé Werner" <***@hotmail.com> wrote:
>Hello
>
>I found out that in some cases rsnapshot's lockfile is not removed
>which makes it issue a warning the next time it runs.
>
>Here is a demonstration :
>
>I'm using the following configuration file :
>
>config file :
>config_version 1.2
>snapshot_root /media/LV_BACKUP/rsnapshot/
>cmd_cp /bin/cp
>cmd_rm /bin/rm
>cmd_rsync /usr/bin/rsync
>cmd_logger /usr/bin/logger
>retain alpha 3
>retain beta 2
>retain gamma 2
>verbose 5
>loglevel 3
>lockfile /var/run/rsnapshot.pid
>one_fs 1
>link_dest 1
>use_lazy_deletes 1
>backup /tmp/test localhost
>
>
>I then execute rsnapshot twice :
>
>$ sudo rsnapshot alpha
>require Lchown
>Lchown module not found
>Setting locale to POSIX "C"
>echo 32014 > /var/run/rsnapshot.pid
>mkdir -m 0755 -p /media/LV_BACKUP/rsnapshot/alpha.0/
>/usr/bin/rsync -avx --delete --numeric-ids --relative --delete-excluded
>\
> /tmp/test/ /media/LV_BACKUP/rsnapshot/alpha.0/localhost
>sending incremental file list
>created directory /media/LV_BACKUP/rsnapshot/alpha.0/localhost
>/tmp/
>/tmp/test/
>/tmp/test/env.txt
>/tmp/test/install-dep.txt
>/tmp/test/install-dep.txt2
>
>sent 38,800 bytes received 152 bytes 77,904.00 bytes/sec
>total size is 38,490 speedup is 0.99
>rsync succeeded
>touch /media/LV_BACKUP/rsnapshot/alpha.0/
>/usr/bin/logger -p user.info -t rsnapshot[32014]
>/usr/local/bin/rsnapshot \
> alpha: completed successfully
>
>
>$ sudo rsnapshot alpha
>require Lchown
>Lchown module not found
>Setting locale to POSIX "C"
>WARNING: Removing stale lockfile /var/run/rsnapshot.pid
>/usr/bin/logger -p user.err -t rsnapshot[32020] WARNING: Removing stale
>\
> lockfile /var/run/rsnapshot.pid
>WARNING: About to remove lockfile /var/run/rsnapshot.pid which belongs
>to a different process: 32014 (this is OK if it's a stale lock)
>rm -f /var/run/rsnapshot.pid
>echo 32020 > /var/run/rsnapshot.pid
>mv /media/LV_BACKUP/rsnapshot/alpha.0/
>/media/LV_BACKUP/rsnapshot/alpha.1/
>mkdir -m 0755 -p /media/LV_BACKUP/rsnapshot/alpha.0/
>/usr/bin/rsync -avx --delete --numeric-ids --relative --delete-excluded
>\
> --link-dest=/media/LV_BACKUP/rsnapshot/alpha.1/localhost \
> /tmp/test/ /media/LV_BACKUP/rsnapshot/alpha.0/localhost
>sending incremental file list
>created directory /media/LV_BACKUP/rsnapshot/alpha.0/localhost
>
>sent 171 bytes received 85 bytes 512.00 bytes/sec
>total size is 38,490 speedup is 150.35
>rsync succeeded
>touch /media/LV_BACKUP/rsnapshot/alpha.0/
>/usr/bin/logger -p user.err -t rsnapshot[32020] WARNING: \
> /usr/local/bin/rsnapshot alpha: completed, but with some warnings
>
>
>Actually according to the source code this behavioir happens when using
>the lazy_delete feature as the lockfile seem to only be removed when a
>_delete directory exists :
>
>## code sub handle_interval
>
> # if use_lazy_delete is on, delete the _delete.$$ directory
># we just check for the directory, it will have been created or not
>depending on the value of use_lazy_delete
> if (-d "$config_vars{'snapshot_root'}/_delete.$$") {
>
> # this is the last thing to do here, and it can take quite a while.
># we remove the lockfile here since this delete shouldn't block other
>rsnapshot jobs from running
> remove_lockfile();
>
>
>So I think rsnapshot should either create a dumb _delete directory if
>there is no previous backup to clean or add something like
>remove_lockfile() if ($use_lazy_deletes).
>
>
>dud
>
>
>------------------------------------------------------------------------
>
>------------------------------------------------------------------------------
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>rsnapshot-discuss mailing list
>rsnapshot-***@lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/rsnapshot-discuss

Without reading your post fully, i would assume, this is fixed in current master.

Search on github.com/rsnapshot/rsnapshot for the term "lockfile stale" and you'll get the corresponding issue.

Please verify if this issue is fixed for you.

Prepare for a release in the next 2 weeks.

Cheers, Bene

PS: sry for short and rude answer, im currently only available on mobile.

------------------------------------------------------------------------------
Benedikt Heine
2015-06-09 12:35:38 UTC
Permalink
On June 9, 2015 2:34:11 PM CEST, "Hervé Werner" <***@hotmail.com> wrote:
>
>> Without reading your post fully, i would assume, this is fixed in
>current master.
>
>Actually I'm already using the last version of the master branch.
>
>>
>> Search on github.com/rsnapshot/rsnapshot for the term "lockfile
>stale" and you'll get the corresponding issue.
>>
>> Please verify if this issue is fixed for you.
>
>Yeah that looks like a good fix, however I think there was an issue
>with the last merge you did because the commit you are refering seems
>to have been overwritten by commit
>a9facbb4e372d6bfcbc9e799e7abcfb00741bb42 (tidy rsnapshot-program.pl).
>
>>
>> Prepare for a release in the next 2 weeks.
>>
>> Cheers, Bene
>>
>> PS: sry for short and rude answer, im currently only available on
>mobile.
>
>OK, no worries ;)
>
>Regards
>dud
>

Ok, let me look over it.

Thx for the report.

~ Bene

------------------------------------------------------------------------------
Benedikt Heine
2015-06-09 14:49:57 UTC
Permalink
Hi dud,

On June 9, 2015 2:34:11 PM CEST, "Hervé Werner" <***@hotmail.com>
wrote:
>Yeah that looks like a good fix, however I think there was an issue
>with the last merge you did because the commit you are refering seems
>to have been overwritten by commit
>a9facbb4e372d6bfcbc9e799e7abcfb00741bb42 (tidy rsnapshot-program.pl).

I checked now the commit. I merged by mistake the wrong changes. The
commit by @myrdd is now in the repository.

Thanks for the report. For myself, I would not have noticed it.

Cheers,
Bene

------------------------------------------------------------------------------
Loading...