[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: Gavin Lambert <gavinl_at_compacsort.com>
Date: 2006-11-06 06:52:02 CET

Quoth Mark Kempster <mailto:mark@kempster.org>:
> 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.
[...]
> 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}"

I would think that'd give quite a large window of opportunity for Bad
Stuff(tm) to happen.

It'd be better methinks if you replaced those last two lines with:

mv "${backupDir}/${reposName}" "${backupDir}/${reposName}.${VER}.old"
mv "${backupDir}/${reposName}.${VER}" "${backupDir}/${reposName}" || rm
-rf "${backupDir}/${reposName}.${VER}"
rm -rf "${backupDir}/${reposName}.${VER}.old"

(the OR clause on the second line is so that if the move fails [probably
because some other process beat it to the name] then it'd clean up after
itself and not leave stray folders behind.)
It won't guarantee that the most recent commit would win (but then
AFAICT neither did yours), but it will win more often than not.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Mon Nov 6 06:52:51 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.