sqlite3: unable to open database

capstranoを使用してapacheを再起動し、アプリケーションにアクセスしてみると…

ActiveRecord::StatementInvalid (SQLite3::SQLException: unable to open database file: UPDATE "filters"
SET "updated_at" = '2009-06-05 01:47:06' WHERE "id" = 1):
...

というエラーが発生しました。database.ymlに記載されているsqlite3のファイルパスは問題がないので困りましたが、調べていくにつれて、ジャーナルファイルの作成に失敗しているようでした。
ジャーナルファイルはsqlite3のデータベースファイルと同じ階層に作成されるのですが、railsのプロセスの所有者がそのディレクトリに対して書き込み権限を保持していませんでした。
これまでジャーナルファイルを意識してきませんでしたが、update文等を発行すると確かに生成されていました。

sqlite> begin transaction;
sqlite> update users set login='hoge' where id=1;
$ ls -la shrimp*
-rw-r--r-- 1 masayuki dev 112640 2009-05-20 10:50 shrimp_production.sqlite3
-rw-r--r-- 1 masayuki dev   2056 2009-06-06 00:20 shrimp_production.sqlite3-journal

http://www.sqlite.org/lockingv3.html#rollback


Any time a process wants to make a changes to a database file, it first records enough information in the rollback journal to restore the database file back to its initial condition. Thus, before altering any page of the database, the original contents of that page must be written into the journal. The journal also records the initial size of the database so that if the database file grows it can be truncated back to its original size on a rollback.

The rollback journal is a ordinary disk file that has the same name as the database file with the suffix "-journal" added.

Oracleでいうところのロールバックセグメントのようなものなのでしょう。ディレクトリに対して書き込み権限を付与したところ、前述のエラーはでなくなりました。