アットウィキロゴ
Railsマルチプラットフォームアプリ作成記録
掲示板 掲示板 ページ検索 ページ検索 メニュー メニュー

Railsマルチプラットフォームアプリ作成記録

mysql_retry_lost_connection

最終更新:

Bot(ページ名リンク)

- view
だれでも歓迎! 編集

Rails>config>mysql_retry_lost_connection

勤務先ではMySQL server has gone awayエラーとかLost connection to MySQL server during queryエラーとかあるので、gemのmysql_retry_lost_connectionを入れているんだけど、僕のウェブアプリでも起こり始めた。

問題のエラー


Mysql::Error: MySQL server has gone away: SELECT * FROM ******************************
/usr/local/lib/[[ruby]]/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract_adapter.rb:219:in `log'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/mysql_adapter.rb:323:in `execute'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/mysql_adapter.rb:608:in `select'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all_without_query_cache'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/query_cache.rb:62:in `select_all'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:661:in `find_by_sql'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/base.rb:1548:in `find_every_with_deleted'
(以下省略)

非常にやっかいな問題。早速解決しよう。

mysql_retry_lost_connectionのインストール


sudo gem install mysql_retry_lost_connection

そして、environment.rbの一番下に、

require 'mysql_retry_lost_connection'

を挿入します。これで終了。

正常にこのプラグインが機能しているかどうかどうやって判断するんだろう。

タグ:

MySQL
+ タグ編集
  • タグ:
  • MySQL
記事メニュー
最近更新されたスレッド
ウィキ募集バナー