On Wed, Apr 26, 2006 at 10:27:57AM -0700, Tyler MacDonald wrote:
> Package: mirror
> Severity: normal
>
> If anonftpsync takes more than 24 hours to run, a new anonftpsync can start
> behind it, and you end up with 2 rsync connections attempting to mirror at
> once.
That's actually supposed to be a feature. The original version of the script
(or at least the one originally committed to CVS in 1998) included the
parameter '-l 43200' to lockfile(1), which makes it override the lockfile
after that many seconds - half a day.
The reason why this is so is quite probably because if you actually have
rsync running for over half a day, you either have major problems with
something, or you shouldn't be running a mirror at all because at these
kinds of (non-)speeds it's pointless. These days we have archive updates
happen twice a day, so that timeout should probably be reduced to quarter
of a day, now that you mention it :)
But the problem there is that we let lockfile(1) just override the old
lockfile, without e.g. checking if any rsync processes are still running.
I actually fixed this in my local scripts, but never got around to
propagating the change to anonftpsync. The thing is, we can do this:
if [ -f "$LOCK" ]; then
if [ "`find $LOCK -maxdepth 1 -amin -360`" = "" ]; then
if ps ax | grep '[r]'sync | grep -q $RSYNC_HOST; then
echo "stale lock found, but a rsync is still running, aiee!"
exit 1
else
echo "stale lock found (not accessed in the last 6 hours), forcing
update!"
rm -f $LOCK
fi
else
echo "current lock file exists, unable to start rsync!"
exit 1
fi
fi
touch $LOCK
That should fix the problem of silent overriding, and it easily avoids
the use of lockfile(1), none of whose features we actually seem to use
(we use '-r 0' which means there's no retrying).
The check for running rsync processes is a bit lame (it probably doesn't
work on non-GNU ps(1) utilities, etc) but it should suffice. If it gets a
false positive, you can tune it further (let us know :), and the cost
of a false positive is just one skipped update which you get notified about
anyway (hopefully).
--
2. That which causes joy or happiness.
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]