MHG
MHG

Reputation: 1411

New sqlite3 database is locked

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?

Upvotes: 1

Views: 2690

Answers (1)

MHG
MHG

Reputation: 1411

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.

Upvotes: 0

Related Questions