could not open database: disk I/O error
(SQLite3::IOException)
ActiveRecord で SQLite3 を利用していて以下のエラーが発生しました。
/usr/local/lib/ruby/site_ruby/1.8/sqlite3/errors.rb:94:in `check': could not open database: disk I/O error (SQLite3::IOException) from /usr/local/lib/ruby/site_ruby/1.8/sqlite3/database.rb:112:in `initialize' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/sqlite3_adapter.rb:13:in `new' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/sqlite3_adapter.rb:13:in `sqlite3_connection' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:291:in `send' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:291:in `connection=' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:259:in `retrieve_connection' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:78:in `connection' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:2438:in `quoted_table_name' ... 6 levels... (snip)
sqlite3/database.rb
def initialize( file_name, options={} ) utf16 = options.fetch(:utf16, false) load_driver( options[:driver] ) @statement_factory = options[:statement_factory] || Statement result, @handle = @driver.open( file_name, utf16 ) ★ Error.check( result, self, "could not open database" ) @closed = false @results_as_hash = options.fetch(:results_as_hash,false) @type_translation = options.fetch(:type_translation,false) @translator = nil @transaction_active = false end
JMeter等でアプリケーションに過負荷を与えると発生することがありました。
ActiveRecord を継承しているモジュールで、timeout を設定している場合、
タイムアウトを超えたときの例外は、「SQLite3::BusyException」ですが、
上記では、「SQLite3::IOException」が発生し待ち状態になる前に、SQLite3 のファイルを open しにいった時点でエラーとなっている様子。
また、アプリケーション側で begin rescue による補足もできず Webサーバ のエラーログに出力されました。
これだと、500 Internal Server Error になってしまうよ。。