No SQLite over NFS

I was recently going to view the contents of a backed up database and ran into the following error:
%sqlite3 backup_db_130614.db
SQLite version 3.7.4
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .tables
Error: disk I/O error
sqlite>

So I pulled another backup, tried again and got the same error and this all repeated a couple of times. After verifying on the live database that all was fine I started looking around for an answer to what was going on with my backups.

As it turns out, you cannot run SQLite over nfs due to locking issues. Simple as that, but perhaps a little less than optimal error message.

From the FAQ over at www.sqlite.org:

This is because fcntl() file locking is broken on many NFS implementations. You should avoid putting SQLite database files on NFS if multiple processes might try to access the file at the same time.

Share

3 thoughts on “No SQLite over NFS

  1. D

    Your comment is awaiting moderation.
    What if there is only a SINGLE process accessing the db over NFS?

  2. henrik Post author

    I also assumed that if there was only a single process accessing the db it should be fine, this is also mentioned in the same FAQ. However it did not work at all when I tried since SQLite simply refused to work with the db at all.

    This behavior should be possible to avoid during compilation or execution by using dot-file locks, see http://www.sqlite.org/compile.html#enable_locking_style, unfortunately I lack the environment to verify that at this time.

    Item 6.0 expands a bit on the problem with nfs and locks http://www.sqlite.org/lockingv3.html.

    Hope this might solve your problem, let me know.

Leave a Reply

Your email address will not be published. Required fields are marked *