新的sqlite3数据库被锁定

New sqlite3 database is locked

我发现新的 sqlite3 数据库文件在我知道的任何使用之前都被锁定了。

sqlite3 new.sqlite
sqlite> SELECT * FROM SQLITE_MASTER;
Error: database is locked

lsof 上的新文件是空的。将数据库文件复制到新位置无济于事。文件权限正常。

我还能如何确定新的 sqlite3 文件可能被锁定的原因?

查看文档,我最好的猜测是发生这种情况是因为数据库文件位于 Vagrant 的 NFS 装载上。根据文档:

One should note that POSIX advisory locking is known to be buggy or even unimplemented on many NFS implementations ... Your best defense is to not use SQLite for files on a network filesystem.

https://www.sqlite.org/lockingv3.html

我能够通过在主机上安装的文件夹上设置文件权限来解决问题。