Can SQLite and TDB databases be used with NFS?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux
  • NFS filesystem

Issue

  • Many popular applications like Firefox and Thunderbird use SQLite and TDB databases, can these types of databases be used with NFS?

Resolution

  • In most cases no. Specific applications may have workarounds or other resolutions see below.

Any database that relies on the underlying filesystem to lock the files should not be used with NFS. If using a database over NFS it is recommended to utilize the locking methods within the database to prevent it from reacting slowly or halting to queries.

Working with GNOME Applications

  • Unfortunately, many GNOME applications utilize SQLite databases to hold their content so it is not recommended to use these applications over NFS filesystems. Instead, the applications that rely on SQlite should either be moved off of the NFS share and used locally or users' GNOME information should be stored locally using the XDG_* environment variables in the users' .bashrc file.

  • To do so, add the following to each users $HOME/.bashrc file:

export XDG_DATA_HOME="/testuser" 
export XDG_CONFIG_HOME="/testuser/.config"
  • Where /testuser represents a directory that will serve as the above users home directory for application data only, and .config will house the users config files. The newly created directory /testuser should have identical permissions of the users home directory:
 # ls -l /home/test*
 drwx--x---+ 68 testuser testuser  4096 May 18 17:35 testuser

 # chmod 710 /testuser
 # chown testuser:testuser /testuser 

Firefox over NFS

  • An update for Red Hat Enterprise Linux 5 and 6 has been released which adds a new configuration option: storage.nfs_filesystem, that can be used to resolve this issue. The errata update can be viewed here: RHSA-2012-1350

  • Once the above errata has been applied the configuration option can be utilized by following the instructions below:

  1. Start Firefox.

  2. Type "about:config" (without quotes) into the URL bar and press the Enter key.

  3. If prompted with "This might void your warranty!", click the "I'll be careful, I promise!" button.

  4. Right-click in the Preference Name list. In the menu that opens, select New -> Boolean.

  5. Type "storage.nfs_filesystem" (without quotes) for the preference name and then click the OK button.

  6. Select "true" for the boolean value and then press the OK button.

Dealing with databases that utilize their own locking methods

  • If utilizing NFSv3 it is recommended to use the nolock mount option when mounting a database that uses it's own locking method:
mount -o nolock server.example.com:/nfs/mount /local/mount
  • NFSv4 does not require the above and will be able to deal with a database that supports its own locking scheme.

Root Cause

  • When accessing a file, NFS locks down the file to prevent other filesystem operations from accessing the file, this is to prevent other applications from writing or reading the files while one application is utilizing the file as applications writing over each other could lead to corruption.

  • Unfortunately, NFS sees the database as a single file versus a file containing multiple entries so writes or reads from the database will lock the entire database down.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments