How to fix Subversion errors after upgrading your Berkeley DB library
After a routine "apt-get upgrade" of Debian testing, I found myself unable to use my Subversion repository. I got an error message when trying to commit a file:
svn: Berkeley DB error while opening environment for filesystem db:
DB_VERSION_MISMATCH: Database environment version mismatch
svn: bdb: Program version 4.3 doesn't match environment version
A note from the Subversion FAQ had this to say:
After upgrading to Berkeley DB 4.3, I'm seeing repository errors.
Normally one can simply run svnadmin recover to upgrade a Berkeley DB repository in-place. However, due to a bug in the way this command invokes the db_recover() API, this won't work correctly when upgrading from BDB 4.0/4.1/4.2 to BDB 4.3.
Use this procedure to upgrade your repository in-place to BDB 4.3:
- Make sure no process is accessing the repository (stop Apache, svnserve, restrict access via file://, svnlook, svnadmin, etc.)
- Using an older svnadmin binary (that is, linked to an older BerkeleyDB):
- Recover the repository: 'svnadmin recover /path/to/repository'
- Make a backup of the repository.
- Delete all unused log files. You can see them by running 'svnadmin list-unused-dblogs /path/to/repeository'
- Delete the shared-memory files. These are files in the repository's db/ directory, of the form __db.00*
The repository is now usable by Berkeley DB 4.3.
As the instructions note, you need a copy of subversion linked with a pre-4.3 version of the Berkeley database library. Subversion uses Berkeley via the APR Library. So we need to install appropriate verions of Berkeley, APR and Subversion.
My notes are below. Note that I installed the APR and Subversion software into a local directory (/home/mk/proj/svn_db/local in my case). Also, my Subversion repository is in /data/svnroot.
Then I executed steps 3 and 4 from the FAQ. At this point, I was able to commit files to my repository again. Link to story# export LD_CONFIG_PATH=/home/mk/proj/svn_db/local
# wget 'http://downloads.sleepycat.com/db-4.2.52.tar.gz'
# tar -xvzf db-4.2.52.tar.gz
# cd db-4.2.52
# cd build_unix
# ../dist/configure
# make
# make install
# wget 'http://archive.apache.org/dist/apr/apr-0.9.5.tar.gz'
# tar -xvzf apr-0.9.5.tar.gz
# cd apr-0.9.5
# ./configure --prefix=/home/mk/proj/svn_db/local
# make
# make install
# wget 'http://archive.apache.org/dist/apr/apr-util-0.9.5.tar.gz'
# tar -xvzf apr-util-0.9.5.tar.gz
# cd apr-util-0.9.5
# ./configure --prefix=/home/mk/proj/svn_db/local --with-apr=/home/mk/proj/svn_db/local --with-berkeley-db=/usr/local/BerkeleyDB.4.2/
# make
# make install
# wget 'http://subversion.tigris.org/downloads/subversion-1.2.3.tar.bz2'
# tar -xvjf subversion-1.2.3.tar.bz2
# cd subversion-1.2.3
# ./configure --prefix=/home/mk/proj/svn_db/local --with-apr=/home/mk/proj/svn_db/local --with-berkeley-db=/usr/local/BerkeleyDB.4.2/
# make
# make install
# su
# /home/mk/proj/svn_db/local/bin/svnadmin recover /data/svnroot
# tar -cvf ~/svnroot_backup.tar /data/svnroot
Technorati tags for this post: programming subversion database linux Tech
Comment by zauron.subs[arroba]gmail.com
Thanks, this story helps me a lot, I've the same problem but to compile I need a couple of exports and --with-apr-util parameter to compile subversion:
# export LD_CONFIG_PATH=/home/mk/proj/svn_db/local
# wget 'http://downloads.sleepycat.com/db-4.2.52.tar.gz'
# tar -xvzf db-4.2.52.tar.gz
# cd db-4.2.52
# cd build_unix
# ../dist/configure
# make
# make install
# wget 'http://archive.apache.org/dist/apr/apr-0.9.5.tar.gz'
# tar -xvzf apr-0.9.5.tar.gz
# cd apr-0.9.5
# ./configure --prefix=/home/mk/proj/svn_db/local
# make
# make install
# export LDFLAGS="-L/usr/local/BerkeleyDB.4.2/lib"
# export LD_LIBRARY_PATH=/usr/local/BerkeleyDB.4.2/lib
# wget 'http://archive.apache.org/dist/apr/apr-util-0.9.5.tar.gz'
# tar -xvzf apr-util-0.9.5.tar.gz
# cd apr-util-0.9.5
# ./configure --prefix=/home/mk/proj/svn_db/local --with-apr=/home/mk/proj/svn_db/local --with-berkeley-db=/usr/local/BerkeleyDB.4.2/
#
# make
# make install
# wget 'http://subversion.tigris.org/downloads/subversion-1.2.3.tar.bz2'
# tar -xvjf subversion-1.2.3.tar.bz2
# cd subversion-1.2.3
# ./configure --prefix=/home/mk/proj/svn_db/local --with-apr=/home/mk/proj/svn_db/local --with-apr-util=/home/mk/proj/svn_db/local --with-berkeley-db=/usr/local/BerkeleyDB.4.2/
# make
# make install
Comment by matt
Comment by <Anonymous>
Make that 2 people at least. I needed the
--with-apr-util
as well
Thanks!
Comment by <Anonymous>
Comment by Jon@jonsthoughtsoneverything.com
./configure --with-apr=/usr/local/apr --with-berkeley-db=/usr/local/BerkeleyDB.4.2/
but it just can't find it.. configure: error: Berkeley DB not found.. whats going on here?
Comment by Bob
Brilliant, thanks Matt for saving me a lot of time (the SVN FAQ advice was
rather too brief).
I managed to do the whole thing in one directory (in my case
/usr/local/svn_rescue) without any need to set LD_*_PATH variables:
[I hope what I paste in below formats OK!]
wget 'http://downloads.sleepycat.com/db-4.2.52.tar.gz'
tar -xvzf db-4.2.52.tar.gz
cd db-4.2.52
cd build_unix
../dist/configure --prefix=/usr/local/svn_rescue
make
make install
wget 'http://archive.apache.org/dist/apr/apr-0.9.5.tar.gz'
tar -xvzf apr-0.9.5.tar.gz
cd apr-0.9.5
./configure --prefix=/usr/local/svn_rescue
make
make install
wget 'http://archive.apache.org/dist/apr/apr-util-0.9.5.tar.gz'
tar -xvzf apr-util-0.9.5.tar.gz
cd apr-util-0.9.5
./configure --prefix=/usr/local/svn_rescue --with-apr=/usr/local/svn_rescue --with-berkeley-db=/usr/local/svn_rescue
make
make install
wget 'http://subversion.tigris.org/downloads/subversion-1.2.3.tar.bz2'
tar -xvjf subversion-1.2.3.tar.bz2
cd subversion-1.2.3
./configure --prefix=/usr/local/svn_rescue --with-apr=/usr/local/svn_rescue --with-apr-util=/usr/local/svn_rescue
+--with-berkeley-db=/usr/local/svn_rescue
make
make install
# then continue with instructions in SVN FAQ
/usr/local/svn_rescue/bin/svnadmin recover /path/to/repository
Comment by Adam
I made a use for this too. I tried over and over again with various builds of BDB, apr, and apr-util. It turned out that I needed to do the following after the BDB build:
cp /usr/local/BerkeleyDB.4.5/libdb-4.5.so /usr/lib
Everything else worked after that.
Comment by Adam
apt-get install libdb4.4-dev
./configure --with-berkeley-db=/usr/include:/usr/lib