[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn ci performance hit with hotcopy as post-commit hook

From: Mark Kempster <mark_at_kempster.org>
Date: 2006-11-02 16:10:20 CET

On Wed, 1 Nov 2006, Ryan Schmidt wrote:

> On Nov 1, 2006, at 16:56, Erik Huelsmann wrote:
>
> >> My biggest problem is the post-commit hook calling svnadmin hotcopy.
> >> The repository (fsfs) only weighs in at 120MB, but it's taking
> >> between
> >> 20 and 30 seconds for the hotcopy to come back, with the client's
> >> checkin transaction dutifully waiting. I fear this pause will be too
> >> long for users.
> >
> > You don't need your clients to wait 20-30 secs iff you detach the
> > hotcopy process from the one doing the commit by issuing in your
> > post-commit:
> >
> > svnadmin hotcopy ... >/dev/null 2>/dev/null &
>
> If two people try to commit in close succession, won't the one backup
> overwrite the other, possibly resulting in a corrupt or at least out-
> of-date backup?

Thanks for the help.

I'm going to try hotcopy'ing to a unique location (backupdir/repos.ver)
to avoid parallel hotcopy processes bashing each other, then rename it
to the 'real' directory (eg. mv backupdir/repos.ver backupdir/repos).
Still exposure with one process bashing each other, but less than the
30-second hotcopy. Client commits return as before, and the server merrily
fires the hotcopy and rotation. It even restores to a remote repository!
I'm thrilled.

If anybody's watching, here's what I did.

(1) post-commit has this
--------------------------------------------------------------------------------
reposLogDir="/opt/log"
reposName=`/bin/basename ${REPOS}`
postcommitLog="${reposLogDir}/${reposName}-postcommit.log"
backupDir="/opt/backups/svn"

${REPOS}/hooks/hotcopy.sh "${REPOS}" "${REV}" "${backupDir}" "${postcommitLog}" >/dev/null 2>/dev/null &
--------------------------------------------------------------------------------

(2) hotcopy.sh has this

--------------------------------------------------------------------------------
#!/bin/sh

REPOS="$1"
VER="$2"
backupDir="$3"
LOG="$4"
reposName=`/bin/basename $REPOS`

# Export to repos.123 (can be slow) to avoid clashes with parallel commits
echo "`date` - Starting hotcopy repos $REPOS to ${backupDir}/${reposName}.${VER}" >> $LOG
/usr/bin/svnadmin hotcopy "$REPOS" "${backupDir}/${reposName}.${VER}" >> $LOG
echo "`date` - Finished hotcopy" >> $LOG

echo "`date` - Rotating export directories ${backupDir}/${reposName}.${VER} to ${backupDir}/${reposName}" >> $LOG
# rename repos.123 to repos (should be fast). Most recent commit wins.
rm -rf "${backupDir}/${reposName}"
mv "${backupDir}/${reposName}.${VER}" "${backupDir}/${reposName}"

echo "`date` - Export process complete." >> $LOG
--------------------------------------------------------------------------------

Next up, post-hotcopy rsync and service failover.
Cheers
- Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Thu Nov 2 16:03:55 2006

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.