You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by kf...@collab.net on 2004/09/17 13:13:22 UTC

Re: Are post-commit hooks atomic?

Dewey Sasser <de...@sasser.com> writes:
> So, does subversion call my post-commit script atomically?  Can I
> count on there *never* being two instances of the script running
> simultaneously?

It is only called once per revision, but there is no guarantee that
one instance of post-commit will have finished before another instance
is called -- indeed, if people are committing fast enough, you can
pretty much guarantee that instances will overlap.

-Karl

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Are post-commit hooks atomic?

Posted by Stefan Haller <ha...@ableton.com>.
Max Bowsher <ma...@ukf.net> wrote:

> Stefan Haller wrote:
> > Ben Collins-Sussman <su...@collab.net> wrote:
> >
> >> So running a 2nd 'svn up'  will just error out as soon as it hits the
> >> other process' lockfile.
> >
> > But then it's not guaranteed that the checked-out live copy is always up
> > to date, is it?  (If the last post-commit hook errors out because the
> > previous one is still running.)
> 
> True.
> 
> Sounds like you need to have your post-commit wait for and acquire a lock
> whilst it is running.

Yes, that's what we did with CVS; I just wanted to be certain whether we
still have to do it with subversion.

(Actually, waiting for a lock is not a suitable solution, because if,
say, five more commits happen while a post-commit hook is still running,
you don't want to run five more "svn up" afterwards, but only one.  This
can easily happen with a very large repository.  What we did is try to
acquire the lock, and if it fails, touch a "there are updates pending"
file (guarded by another lock); if we manage to acquire the lock, we run
"cvs up" in a loop as long as the "there are updates pending" file
exists.  I think I should clean up the code a bit and submit it for the
contrib directory, since it is a solution to what I think must be a very
common problem.)


-- 
Stefan Haller
Ableton
http://www.ableton.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Are post-commit hooks atomic?

Posted by Max Bowsher <ma...@ukf.net>.
Stefan Haller wrote:
> Ben Collins-Sussman <su...@collab.net> wrote:
>
>> So running a 2nd 'svn up'  will just error out as soon as it hits the
>> other process' lockfile.
>
> But then it's not guaranteed that the checked-out live copy is always up
> to date, is it?  (If the last post-commit hook errors out because the
> previous one is still running.)

True.

Sounds like you need to have your post-commit wait for and acquire a lock 
whilst it is running.

Max.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Are post-commit hooks atomic?

Posted by Stefan Haller <ha...@ableton.com>.
Ben Collins-Sussman <su...@collab.net> wrote:

> So running a 2nd 'svn up'  will just error out as soon as it hits the
> other process' lockfile.

But then it's not guaranteed that the checked-out live copy is always up
to date, is it?  (If the last post-commit hook errors out because the
previous one is still running.)


-- 
Stefan Haller
Ableton
http://www.ableton.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Are post-commit hooks atomic?

Posted by Ben Collins-Sussman <su...@collab.net>.
On Sep 18, 2004, at 3:03 AM, Stefan Haller wrote:

> <kf...@collab.net> wrote:
>
>> Dewey Sasser <de...@sasser.com> writes:
>>> So, does subversion call my post-commit script atomically?  Can I
>>> count on there *never* being two instances of the script running
>>> simultaneously?
>>
>> It is only called once per revision, but there is no guarantee that
>> one instance of post-commit will have finished before another instance
>> is called -- indeed, if people are committing fast enough, you can
>> pretty much guarantee that instances will overlap.
>
> OK, so is it safe to call several "svn up" on the same working copy
> concurrently?

When 'svn up' enters a directory to update it, it drops a lockfile.  
(Actually, this is true of any svn subcommand that changes working copy 
data.)   This prevents another process from changing things in the 
directory.... in other words, only one process can have a directory 
open for "writing" at any given time.  So running a 2nd 'svn up'  will 
just error out as soon as it hits the other process' lockfile.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Are post-commit hooks atomic?

Posted by Stefan Haller <ha...@ableton.com>.
<kf...@collab.net> wrote:

> Dewey Sasser <de...@sasser.com> writes:
> > So, does subversion call my post-commit script atomically?  Can I
> > count on there *never* being two instances of the script running
> > simultaneously?
> 
> It is only called once per revision, but there is no guarantee that
> one instance of post-commit will have finished before another instance
> is called -- indeed, if people are committing fast enough, you can
> pretty much guarantee that instances will overlap.

OK, so is it safe to call several "svn up" on the same working copy
concurrently?  That's what could happen if you put svn up in a
post-commit hook to get, say, a live web site of the repo's HEAD.

I know this is isn't safe with CVS, so we had to implement some
complicated locking mechanism ourselves.  Just wondering if we have to
keep doing that with svn.


-- 
Stefan Haller
Ableton
http://www.ableton.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org