New sqlite3 database is locked

会有一股神秘感。 提交于 2019-12-12 03:39:18

问题


I'm finding that new sqlite3 database files are locked before any use that I am aware of.

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

lsof on the new file is empty. Copying the database file to a new location doesn't help. Permissions on the file are OK.

How else can I determine why a new sqlite3 file might be locked?


回答1:


Looking at the docs, my best guess is that this is occuring because the database file is on an NFS mount for Vagrant. According to the docs:

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

I was able to resolve the issue by setting file permissions on the mounted folder on the host machine.



来源:https://stackoverflow.com/questions/38673701/new-sqlite3-database-is-locked

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!