2

I'm trying to create a new database using sqlite but I keep getting the following error:

sqlite3 new.db
SQLite version 3.3.6
Enter ".help" for instructions
sqlite> begin immediate;
SQL error: database is locked

I tried building the latest sqlite from source and I get the following error:

sqlite3 new.db
SQLite version 3.8.8.3 2015-02-25 13:29:11
Enter ".help" for usage hints.
Error: disk I/O error

I have free disk space and I tried creating a copy of database file as suggested in disk I/O error with SQLite but without any luck.

All solutions to similar questions point to an issue where the database is locked by another process. But that shouldn't happen in this case.

It looks like an environment problem, but I don't have any idea about the source of this problem.

Has anyone come across something similar?

EDIT: This error was caused by the filesystem. The filesystem in question was an older version and evidently it didn't support cluster locking. There are many other SO questions regarding sqlite databases on nfs.

Community
  • 1
  • 1
Diljot
  • 108
  • 1
  • 1
  • 10

3 Answers3

4

This error was caused by the filesystem. The filesystem in question was an older version and evidently it didn't support cluster locking. There are many other SO questions regarding sqlite databases on nfs.

some of the duplicates are:

Locking sqlite file on NFS filesystem possible?

How to ensure a safe file sync with sqlite and NFS

Community
  • 1
  • 1
Diljot
  • 108
  • 1
  • 1
  • 10
1

Depending on the distribution you can get this error if SELinux or AppArmor is enabled.

  • I checked and SELinux is disabled on the system. I've been looking into it and this seems like a filesystem issue (I just found out that I get this error only when I try creating the database on a mounted filesystem). I've changed my original question. – Diljot Mar 25 '15 at 17:06
1

This can also happen if the database file is writable, but the journal file (same name with -journal appended) is not writable. If the database file isn't writable, then you get attempt to write to a readonly database.

Alan Robertson
  • 441
  • 1
  • 4
  • 7