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

RE: Recover a corrupt repository

From: Jonathan Ashley <jonathan.ashley_at_praxis-his.com>
Date: 2007-12-14 10:36:55 CET

> > Be *very* careful using svnsync in a post-commit script directly.
> > The locking
> > method does not really work properly, and if two users commit
> > simultaneously, the target repository becomes broken. This has
> > happened to me.
> >
> > I worked around it by writing a small daemon process that
> listens for
> > incoming TCP/IP connections on a port and runs svnsync as a result.
> > The post-
> > commit hook just makes this connection. That guarantees
> that only one
> > svnsync will run at a time.
>
> But... but... but... only one commit can happen at a time.
> And the commit is not over until the post-commit script has
> finished running.
> Therefore, if you run svnsync in the post-commit hook, there
> can already only be one svnsync process running at a time.

Well I could be wrong of course, but I think I've got some
pretty convincing evidence that that isn't the case. Also, since
I did my fix it hasn't happened again, though I realise that
doesn't mean much.

Here's a (small, slightly doctored) chunk of the Apache server
log of the backup machine:

"10.1.8.1 - project-svnowner [13/Jul/2007:16:00:29 +0100] "PROPPATCH /svn/imp/!svn/bln/0 HTTP/1.1" 207 428
10.1.8.1 - - [13/Jul/2007:16:02:05 +0100] "PROPFIND /svn/imp HTTP/1.1" 401 544
10.1.8.1 - - [13/Jul/2007:16:02:05 +0100] "PROPFIND /svn/imp HTTP/1.1" 401 544
10.1.8.1 - project-svnowner [13/Jul/2007:16:02:05 +0100] "PROPFIND /svn/imp HTTP/1.1" 207 645"

That PROPFIND with no user name is the first thing you see
when an svnsync runs. Note the two of them at exactly the same
time.

Our setup is that we have a main server called 'project', which
runs svnsync in a post-commit script. The svnsync target
repository is on a machine called 'project-standby'.

All users can commit to the repository on the main machine.
Authentication is done by Apache using the mod_auth_sspi
module, and authorisation is done using mod_authz_svn.
Apache itself runs as a user called 'project-svnowner' and
writes to the repository under that id. On the standby
machine, only the 'project-svnowner' user is allowed to
commit, and the svnsync process authenticates as this user.
No regular users know the 'project-svnowner' password - this
is to prevent regular users from being able to commit to the
standby repository.

The environment on both machines is Apache 2.2.4 with
Subversion 1.4.3 on Windows Server 2003.

This is the log (again, slightly doctored to remove paths,
user names or log messages) from the relevant area of the
repository on 'project':

--- cut here

$ svn log -v -r 45785:45787 http://project/svn/imp
------------------------------------------------------------------------
r45785 | user.one | 2007-07-13 16:02:02 +0100 (Fri, 13 Jul 2007) | 2 lines Changed paths:
   D <path_one>

<comment one>
------------------------------------------------------------------------
r45786 | user.two | 2007-07-13 16:02:02 +0100 (Fri, 13 Jul 2007) | 2 lines Changed paths:
   M <path_two>

<comment two>
------------------------------------------------------------------------
r45787 | user.one | 2007-07-13 16:02:43 +0100 (Fri, 13 Jul 2007) | 2 lines Changed paths:
   M <path_three>

<comment three>
------------------------------------------------------------------------

--- cut here

This is the log from the relevant area of the repository on 'project-standby':

--- cut here

$ svn log -v -r 45785:HEAD http://project-standby/svn/imp
------------------------------------------------------------------------
r45785 | user.one | 2007-07-13 16:02:02 +0100 (Fri, 13 Jul 2007) | 2 lines Changed paths:
   D <path_one>

<comment one>
------------------------------------------------------------------------
r45786 | project-svnowner | 2007-07-13 16:02:07 +0100 (Fri, 13 Jul 2007) | 1 line

------------------------------------------------------------------------
r45787 | project-svnowner | 2007-07-13 16:02:09 +0100 (Fri, 13 Jul 2007) | 1 line

Changed paths:
   M <path_two>

------------------------------------------------------------------------

--- cut here

As you can see, revision 45785 is copied correctly at time
16:02:02, but then revision 45786 is created apparently out
of nowhere on the standby machine at 16:02:07. This revision
contains absolutely no data as far as I can tell - no file
updates, no property updates and no revision properties
except for svn:author, svn:date and an empty svn:log.

The main machine then seems to have copied over its revision
45786, which appears on the standby machine as 45787, with
the wrong user id. After this, svnsync realises the
destination repository is broken and refuses to commit any
further changes. The message from svnsync when this is
attempted is:

"svnsync: Revision being currently copied (45786), last merged revision (45785), and destination HEAD (45787) are inconsistent; have you committed to the destination without using svnsync?"

The revision properties on revision 0 of the destination
repository are:

"$ svn pl -v --revprop -r 0 http://project-standby/svn/imp Unversioned properties on revision 0:
  svn:sync-from-uuid : 006e8326-849b-5342-973c-c0a76f4d689d
  svn:sync-currently-copying : 45786
  svn:sync-last-merged-rev : 45785
  svn:date : 2006-02-13T14:02:09.906250Z
  svn:sync-from-url : http://project/svn/imp"

For completeness, the content of revision 45786 on the
standby machine is:

"$ svnadmin dump imp -r 45786 --incremental
SVN-fs-dump-format-version: 2

UUID: 006e8326-849b-5342-973c-c0a76f4d689d

Revision-number: 45786
Prop-content-length: 110
Content-length: 110

K 7
svn:log
V 0

K 10
svn:author
V 15
project-svnowner
K 8
svn:date
        V 27
2007-07-13T15:02:07.489739Z
PROPS-END

* Dumped revision 45786."

This email is confidential and intended solely for the use of the individual to whom it is addressed. If you are not the intended recipient, be advised that you have received this email in error and that any use, disclosure, copying or distribution or any action taken or omitted to be taken in reliance on it is strictly prohibited. If you have received this email in error please contact the sender. Any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Praxis.

Although this email and any attachments are believed to be free of any virus or other defect, no responsibility is accepted by Praxis or any of its associated companies for any loss or damage arising in any way from the receipt or use thereof. The IT Department at Praxis can be contacted at it.support@praxis-his.com.

Praxis High Integrity Systems Ltd:

Company Number: 3302507, registered in England and Wales

Registered Address: 20 Manvers Street, Bath. BA1 1PX

VAT Registered in Great Britain: 682635707

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Fri Dec 14 10:37:26 2007

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.