When working with Subversion (SVN), the system uses file locks to maintain data integrity during operations. The error message you're seeing indicates SVN can't obtain an exclusive lock on the transaction file:
svn: Can't get exclusive lock on file '/svn/repo/db/transactions/7802-2.txn/rev-lock': No locks available
This typically happens when the underlying filesystem (in your case, NFS) isn't properly releasing locks after a crash.
NFS locking has several known pain points:
1. Lock recovery after server crashes can be unreliable
2. Network timeouts may leave stale locks
3. Client and server locking implementations sometimes disagree
The recent NFS server crash is almost certainly the root cause. When the server went down, it left lock state information that wasn't properly cleaned up during recovery.
Try these steps in order until the issue resolves:
1. Clear NFS locks on the server:
sudo nfsiostat
sudo /usr/sbin/rpc.lockd -h
sudo /sbin/service nfslock restart
2. Verify lock status:
sudo lslocks | grep svn
sudo /usr/sbin/rpcinfo -p
3. Manually remove stale locks (as last resort):
cd /svn/repo/db/transactions
find . -name "*lock" -exec ls -la {} \;
# If absolutely certain they're stale:
find . -name "*lock" -exec rm -f {} \;
Consider these configuration improvements:
1. NFS mount options:
# In /etc/fstab
svnserver:/svn/repo /mnt/svn nfs rw,hard,intr,timeo=600,retrans=2 0 0
2. SVN server tuning:
# In repo/conf/svnserve.conf
[general]
lock-method = fcntl
# or for some NFS versions
lock-method = dot-file
3. Monitoring solution:
Add this cron job to check for stale locks daily:
0 3 * * * /usr/bin/flock -n /tmp/svnlockcheck.lock -c "find /svn/repo -name '*lock' -mtime +1 -exec ls -la {} \; > /var/log/svn_stale_locks.log"
If this becomes a chronic issue:
1. Consider migrating to HTTP(S) access via Apache/mod_dav_svn
2. Evaluate if Git would better suit your workflow
3. For critical repos, use local storage instead of NFS
When working with Subversion (SVN) repositories mounted via NFS, you might encounter the frustrating "No locks available" error during commit operations. The error typically appears as:
svn: Can't get exclusive lock on file '/svn/repo/db/transactions/7802-2.txn/rev-lock': No locks available
The root cause often relates to stale NFS locks that weren't properly released when the NFS server crashed. SVN relies on file locking mechanisms to maintain repository integrity, and NFS implementations sometimes fail to clean up locks after unexpected shutdowns.
Try these quick fixes first:
# 1. Unmount and remount the NFS share
sudo umount /svn/repo
sudo mount -t nfs nfs-server:/path /svn/repo
# 2. Clear NFS stale locks (Linux specific)
sudo rpc.statd --force
sudo service nfslock restart
For more persistent cases, consider these approaches:
# 1. Adjust NFS mount options (add to /etc/fstab)
nfs-server:/path /svn/repo nfs rw,hard,intr,noatime,timeo=300,retrans=5 0 0
# 2. Configure SVN to use DB backend instead of FSFS
svnadmin create --fs-type bdb /path/to/newrepo
To investigate current lock status:
# Check NFS lock status
sudo /usr/sbin/nfsstat -l
# List open files (including locks)
sudo lsof | grep '/svn/repo'
# Check for stale NFS handles
sudo cat /proc/fs/nfsd/unlock
Implement these best practices to avoid future occurrences:
- Use NFSv4 instead of NFSv3 (better locking implementation)
- Configure proper NFS server monitoring
- Implement regular repository verification checks
As a last resort, you might need to:
- Create a new repository
- Dump and load the existing repository
- Verify the new repository's integrity
svnadmin dump /svn/repo > repo.dump
svnadmin create /svn/newrepo
svnadmin load /svn/newrepo < repo.dump