错误信息

执行svn sync命令做svn同步时遇到Failed to get lock on destination repos, currently held by ...错误信息如下所示:

1
2
3
4
5
6
7
8
9
10
11
12
C:\Users\ZSYY\Repositories>svnsync init file:///C:\Users/ZSYY/Repositories/Study svn://1.14.104.184/ --allow-non-empty
Failed to get lock on destination repos, currently held by 'ZSYY-PC:2784d6ff-ab53-9041-9267-76f7603f08d6'
Failed to get lock on destination repos, currently held by 'ZSYY-PC:2784d6ff-ab53-9041-9267-76f7603f08d6'
Failed to get lock on destination repos, currently held by 'ZSYY-PC:2784d6ff-ab53-9041-9267-76f7603f08d6'
Failed to get lock on destination repos, currently held by 'ZSYY-PC:2784d6ff-ab53-9041-9267-76f7603f08d6'
Failed to get lock on destination repos, currently held by 'ZSYY-PC:2784d6ff-ab53-9041-9267-76f7603f08d6'
Failed to get lock on destination repos, currently held by 'ZSYY-PC:2784d6ff-ab53-9041-9267-76f7603f08d6'
Failed to get lock on destination repos, currently held by 'ZSYY-PC:2784d6ff-ab53-9041-9267-76f7603f08d6'
Failed to get lock on destination repos, currently held by 'ZSYY-PC:2784d6ff-ab53-9041-9267-76f7603f08d6'
Failed to get lock on destination repos, currently held by 'ZSYY-PC:2784d6ff-ab53-9041-9267-76f7603f08d6'
Failed to get lock on destination repos, currently held by 'ZSYY-PC:2784d6ff-ab53-9041-9267-76f7603f08d6'
svnsync: E000022: Couldn't get lock on destination repos after 10 attempts

出现问题的原因

发生以上情况的有以下几种情况:

  1. 有正在同步的进程未完成,lock未释放;
  2. 上一次同步的进程异常导致中断,lock未释放。
  3. 有svn冲突

SVN同步时,源库端会在目标库端加lock,成功同步后释放lock,但当SVN同步异常中断后,lock是不会自动释放的。这时在执行svn sync命令,就会出现如上问题。

解决方案

执行以下命令:

1
svn propdel svn:sync-lock --revprop -r 0 http://192.168.xx.xx/仓库(svn仓库地址)

将lock释放即可再次执行同步。

1
svn propdel svn:sync-lock --revprop -r 0 file:///www/svndata/test

我自己操作成功的命令如下所示:

1
2
C:\Users\ZSYY\Repositories>svn propdel svn:sync-lock --revprop -r 0 file:///C:\Users\ZSYY\Repositories\Study
property 'svn:sync-lock' deleted from repository revision 0