新的sqlite3数据库已锁定 [英] New sqlite3 database is locked

查看:307
本文介绍了新的sqlite3数据库已锁定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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为空.将数据库文件复制到新位置无济于事.该文件的权限还可以.

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

我还能如何确定为什么新的sqlite3文件可能被锁定?

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

推荐答案

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

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:

请注意,已知POSIX咨询锁定存在漏洞或 甚至在许多NFS实现中都没有实现...您的最佳防御 是不要将SQLite用于网络文件系统上的文件.

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

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

这篇关于新的sqlite3数据库已锁定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆