[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

anonftpsync and two pushes close to one another

Václav Ovsík's mail about checking for a clean archive before syncing
reminded me of a similar issue I fixed in one of my setups which are
based on the d.o mirror pushing scheme.

The problem occurs when a second push comes in while the first is still
updating.  The second sync run gets aborted "'current lock file
exists, unable to start rsync!' && exit 1" while the first still runs.

Depending on when the first rsync run was started, by the time it
finishes we have an inconsistent copy of the archive, since obviously it
was changed while we were updating (why else would we have gotten a
second push).  And the sync run the second push started already exited.

The solution I chose was that every push touches a file "mirror update
required", and the current running sync script runs as long as that file

Something like this:

HOSTNAME=`hostname -f`


# Check to see if another sync is in progress
if lockfile -! -l 43200 -r 0 "$LOCK"; then
        echo "[$$] $HOSTNAME is unable to start rsync, lock file exists"
        exit 1
echo "[$$] Acquired main lock"
trap "rm -f '$LOCK' > /dev/null 2>&1" exit

while [ -e "$UPDATEDREQUIRED" ]; do
        rm -f "$UPDATEDREQUIRED"
        rsync --recursive --times --links --hard-links \
                --verbose --stats \
                --exclude "Archive-Update-in-Progress-${HOSTNAME}" \
                --exclude "Archive-Update-Process-Waiting-${HOSTNAME}" \
                "$FROM" "$TO"

savelog "$LOG" > /dev/null 2>&1
rm -f "$LOCK" > /dev/null 2>&1

(note that this has the actual rsync step greatly simplified because
it's from an svnsync, not a debian archive sync)

Maybe who ever tends to anonftpsync these days should also implement
this logic.


Reply to: