当我尝试向 Subversion 存储库提交更改时,我收到以下形式的错误消息
svn: E000037: Commit failed (details follow):
svn: E000037: Can't get exclusive lock on file '/path/to/repo/db/txn-current-lock': No locks available
svn: E000037: Your commit message was left in a temporary file:
svn: E000037: '/path/to/workdir/svn-commit.tmp'
可能是什么原因?
答案1
Subversion 代码结束尝试获取锁txn-current-lock
通过调用该文件apr_file_lock()
。您应该能够通过以下测试重现该错误:
#include <apr_general.h>
#include <apr_file_io.h>
#include <apr_pools.h>
#include <stdio.h>
int main(int argc, const char * const *argv, const char * const *env) {
apr_file_t *f;
apr_pool_t *pool;
apr_status_t err;
char errbuf[200];
if (argc <= 1) {
fprintf(stderr, "Error: Need to specify path to file to lock\n");
return 1;
}
apr_app_initialize(&argc, &argv, &env);
if (0 != (err = apr_pool_create(&pool, NULL))) {
fprintf(stderr, "Failed to create APR pool\n");
return 1;
}
if (0 != (err = apr_file_open(&f, argv[1], APR_FOPEN_CREATE | APR_FOPEN_WRITE, APR_UREAD | APR_UWRITE, pool))) {
apr_strerror(err, errbuf, sizeof(errbuf));
fprintf(stderr, "Open failed: %s\n", errbuf);
return 1;
}
if (0 != (err = apr_file_lock(f, APR_FLOCK_EXCLUSIVE | APR_FLOCK_NONBLOCK))) {
apr_strerror(err, errbuf, sizeof(errbuf));
fprintf(stderr, "Lock failed: %s\n", errbuf);
return 1;
}
if (0 != (err = apr_file_unlock(f))) {
apr_strerror(err, errbuf, sizeof(errbuf));
fprintf(stderr, "Unlock failed: %s\n", errbuf);
return 1;
}
apr_pool_destroy(pool);
apr_terminate();
printf("OK\n");
return 0;
}
确保安装了apr-devel
RPM 软件包或libapr1-dev
Debian 软件包或等效软件包,然后使用以下命令构建并运行测试
cc -o locktest locktest.c $(apr-1-config --includes --cflags --link-ld --libs)
./locktest /path/to/repo/db/txn-current-lock
...如果使用 Subversion 服务器,最好以 Web 服务器用户身份运行。
无法获得锁定的一个令人惊讶的可能原因是,如果存储库驻留在使用 NFS 挂载的文件系统上,并且 NFS 客户端无法写入/var/lib/nfs
(可能是由于/var
分区已满)。