linux - 在整个系统中锁定 sqlite

标签 linux sqlite debian nfs

我的系统出了大问题。不知何故,整个 sqlite 系统都被锁定了。我不是在谈论单个数据库,而是在谈论系统中的每个数据库。

ladb08@newcastle:~$ touch new.sqlite3
ladb08@newcastle:~$ sqlite3 new.sqlite3 
SQLite version 3.7.3
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .tables
Error: database is locked
sqlite> 

同样的问题连firefox都打不开。 我不知道为什么会这样。 这个服务器是一个 debian 服务器,我的团队用它来开发一些带有 rails 的站点。我们将这些东西集中在一个外部 git 仓库中,这样每个人都可以与他自己的用户一起工作,并使用他自己的东西副本。

另一个测试:

ladb08@newcastle:~/agendador/db$ lsof test.sqlite3 
ladb08@newcastle:~/agendador/db$ fuser test.sqlite3 
ladb08@newcastle:~/agendador/db$ strace -e fcntl sqlite3 test.sqlite3 .tables
fcntl(3, F_GETFD) = 0
fcntl(3, F_SETFD, FD_CLOEXEC) = 0
fcntl(4, F_GETFD) = 0x1 (flags FD_CLOEXEC)
fcntl(3, F_SETLK, {type=F_RDLCK, whence=SEEK_SET, start=1073741824, len=1}) = -1 ENOLCK (No locks available)
Error: database is locked

没有人在使用数据库。清空新的也会发生同样的情况。

============================================= ============================

更多信息:

root@newcastle:~# cd /home/ladb08/agendador/db/            
root@newcastle:/home/ladb08/agendador/db# sqlite3 test.sqlite3
SQLite version 3.7.3
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .tables
Error: database is locked
sqlite> .exit

问题,和往常一样。

root@newcastle:~# cd /root           
root@newcastle:~# cp /home/ladb08/agendador/db/test.sqlite3 ./
root@newcastle:~# sqlite3 test.sqlite3
SQLite version 3.7.3
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .tables
agendamentos              prefeituras               tipo_atendimentos      
bloqueios                 profissionais             tipo_situacoes         
cidadaos                  schema_migrations         tmibges                
escalas                   tcbos                     tufibges               
orgaos                    tconselhos             
orgaos_tipo_atendimentos  tipo_acoes             

在nfs分区之外,同一个文件没问题。

root@newcastle:~# mount
(...)
rootfs on / type rootfs (rw)
urquell.home2:/home2/home-newcastle on /home type nfs (rw,v3,addr=10.17.116.3)
fusectl on /sys/fs/fuse/connections type fusectl (rw)

最佳答案

错误代码 ENOLCK 当内核用完锁内存(在您的情况下不太可能)或当对远程文件系统(如 NFS)的锁定操作失败时返回。

显然,您的文件服务器配置为不支持文件锁定。
(这是否是个好主意 is debatable 。)

关于linux - 在整个系统中锁定 sqlite,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16463266/

相关文章:

objective-c - 用于在 Core Data 中执行计算的链式表达式

android - 如果嵌套事务失败,父事务也会失败吗

linux - 哪些 Linux 官方发行版小于 100mb?

ios - 通读我的应用程序的核心数据文件(.sqlite、.sqlite-wal)

svg - 是否有提供错误消息的 SVG 查看器?

c++ - CMake 错误 : variable is NOTFOUND. ACE_INCLUDE_DIR(高级)

linux - 正确分配堆栈以克隆线程

c - 在 C 中使用 open() 函数创建的文件的默认访问模式是什么?

linux - 删除除每个前缀的最近 n 个文件之外的所有文件(基于文件日期)?

ruby - 从 Ubuntu 从 Ruby on Rails 连接到 MSSQL