0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Docker for Windows + SQLite3の環境でUnable to execute statement: disk I/O error が発生する

Posted at

概要

Docker for Windowsのコンテナ内で動いているPHP + SQLite3の環境において、Insert・Update・Delete時に高頻度で「Unable to execute statement: disk I/O error」が発生する。
再度実行するとエラーなく実行ができたりし、一貫性がない。

同じコンテナをLinux系のサーバー上で動かした場合は同エラーが発生しない。

解決

SQLiteのジャーナルモードが「delete」だと本現象が発生し、「wal」だと発生しない。

次のコマンドでSQLiteのジャーナルモードをwalに変更した。

PRAGMA journal_mode=wal

注意点

当然のことながら、ジャーナルモードを変更することでDBへの書き込み動作が変更される。

デフォルトのdeleteモードではcommitごとにDBファイルへ内容が反映されるが、walモードではDBとの接続をクローズするタイミングでの反映となるため、それまでの間にトラブルがあった場合情報が失われる可能性がある。

システムの要件に応じて対応する必要がある。

なんかもっと根本的な解決策がある気がする…

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?