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

Corrupt database and fix

From: Larry Hutchinson <larryh_at_wavemetrics.com>
Date: 2005-01-10 18:22:33 CET

A few days ago the svn database we use for our web pages
became corrupt. This was after the machine hung and had
to be reset. Svn was NOT being used at the time of the
reset and I don't know for a fact that the reset was the cause.

System: Mac OS X 10.3.7
Svn: 1.1.2 served via svnserve
error message from svnlook youngest webrep:

subversion/libsvn_fs_base/bdb/bdb-err.c:74: (apr_err=160029)
svn: Berkeley DB error while checkpointing after Berkeley DB transaction for filesystem webrep/db:
Invalid argument
subversion/libsvn_fs_base/fs.c:306: (apr_err=0)
svn: bdb: DB_ENV->log_flush: LSN of 32/1821 past current end-of-log of 31/1033488
subversion/libsvn_fs_base/fs.c:306: (apr_err=0)
svn: bdb: Database environment corrupt; the wrong log files may have been removed or incompatible database files imported from another environment
subversion/libsvn_fs_base/fs.c:306: (apr_err=0)
svn: bdb: nodes: unable to flush page: 0
subversion/libsvn_fs_base/fs.c:306: (apr_err=0)
svn: bdb: txn_checkpoint: failed to flush the buffer cache Invalid argument

With help from http://svn.haxx.se/users/archive-2004-11/1476.shtml
I was able to recover the database. I list the exact steps here
in the hope of helping other unix wienies. You will need to substitute
your own names and paths.

BTW: I am not a member of this mailing list. I read it via the
web archives.

cd /Users/svn/
su svn
cd webrep/db
rm __db* log.*
/usr/local/BerkeleyDB.4.2/bin/db_recover -cv
cd ../..
svnlook youngest webrep
(printed 38)
cd webrep/db
rm __db* log.*
/usr/local/BerkeleyDB.4.2/bin/db_recover -cv
svnadmin dump webrep > webrepdump
(prints:
* Dumped revision 0.
...
* Dumped revision 38
)

(perhaps what is important is to do the dump right
after a recover and not after a look)

To recreate:
mv webrep webrepJunk
svnadmin create webrep
svnadmin load webrep < webrepdump
cp webrepJunk/conf/* webrep/conf/

?? could the load have been into original webrep dir ??

Back this puppy up:
tar -czf webrep050109.tgz webrep/

**********
My first attempt similar to the above failed so I devised and partly
tested the following scheme. I list this here just in case it becomes
necessary in the future. My latest checked out files were in
a directory named WebSource5.

To update the latest svn backup with current files
after a database corruption:
a. Restore db directory from backup.
        Check permissions and fix if needed
b. Archive latest checkout.
c. Remove all .svn directories from latest checkout:
        cd WebSource5
        find . -name '.svn' -print | xargs rm -r
d. Create tarball
        cd ..
        tar -czf latest.tgz WebSource5/
e. Remove and recreate checkout:
        rm -r WebSource5
        mkdir WebSource5
        cd WebSource5
        svn co svn://yourhost/your/path
f. Remove everything except .svn dirs:
        find . -name "*\.?*" -not -path "*\.svn*" -print0 | xargs -0 rm
g. untar into purged dir:
        cd ..
        tar -xzf latest.tgz
h. Use svn to check in changes since last backup

-- 
Larry Hutchinson
WaveMetrics
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Tue Jan 11 00:12:00 2005

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