Tuesday 7 October 2008

How-to fix SVN's bug 160004: corrupted file system.

My notes on the subject... The idea is generally to revert to the last sucessful commit, then work from there. It's less than ideal, but at least it's relatively safe to do, and easy.

First, find the commit that broke things:

svnlook youngest /path/to/repository
Next, check whether the commit was successful, and proceed on backwards in revision numbers until you find one that works:

svnadmin dump /path/to/repository -r rev_number_from_svnlook --incremental > /home/mtrudel/rev_dump.svndump
If it works, you're stuck. If it fails, and it should, continue on to the previous build (current_build - 1), if it succeeds, you can do the following:

  • Edit /path/to/repository/db/current, change the first item (revision number) to the revision that works.
  • Try to checkout -- things should work.
  • Try to checkin changes -- things should work.
You should obviously do this with exclusive access to the SVN repository you're trying to fix, *just in case*, so shutdown Apache, svnserve or whatever else may be publishing the repository.

Other details:
  • svnadmin verify is a bad idea on repos with a large number of commits, if resolution time is critical and the information in the last commit is not too important.
  • Take backups of any files you modify.

No comments: