1

私は他の誰かが遭遇したかどうか疑問に思っている resque 仕事で奇妙な問題を抱えています。

jruby 1.6.2 で resque を実行しています。

さまざまな URL から一連のファイルをダウンロードし、それらのファイルを Fog を使用して Rackspace Cloudfiles にアップロードし、それらのファイルに関する情報を MySQL に保存する、長時間実行されるタスクがあります。これがしばらく続くと、アプリケーションのネットワーク スタックが機能しなくなったようです。ある例では、失敗の最初の兆候はここからのタイムアウトでした:

org/jruby/ext/openssl/SSLSocket.java:512:in `sysread'
/var/www/lisausa/shared/bundle/jruby/1.9/gems/jruby-openssl-0.7.4/lib/openssl/buffering.rb:35:in `fill_rbuff'
/var/www/lisausa/shared/bundle/jruby/1.9/gems/jruby-openssl-0.7.4/lib/openssl/buffering.rb:158:in `eof?'
/var/www/lisausa/shared/bundle/jruby/1.9/gems/jruby-openssl-0.7.4/lib/openssl/buffering.rb:133:in `readline'
/var/www/lisausa/shared/bundle/jruby/1.9/gems/excon-0.6.5/lib/excon/response.rb:22:in `parse'
/var/www/lisausa/shared/bundle/jruby/1.9/gems/excon-0.6.5/lib/excon/connection.rb:174:in `request'
/var/www/lisausa/shared/bundle/jruby/1.9/gems/fog-0.11.0/lib/fog/core/connection.rb:20:in `request'
/var/www/lisausa/shared/bundle/jruby/1.9/gems/fog-0.11.0/lib/fog/storage/rackspace.rb:107:in `request'

通常、これらの問題は、ジョブ実行の約 10 ~ 15 分後に発生します。その後、データベースへの書き込みを試行するたびにこれが表示され始めます...

ActiveRecord::JDBCError: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.: SELECT `bills`.* FROM `bills` WHERE (`bills`.state_session_id = 59)
ActiveRecord::StatementInvalid: ActiveRecord::JDBCError: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.: SELECT `bills`.* FROM `bills` WHERE (`bills`.state_session_id = 59)
/var/www/lisausa/shared/bundle/jruby/1.9/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract_adapter.rb:207:in `log'
/var/www/lisausa/shared/bundle/jruby/1.9/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract_adapter.rb:200:in `log'
/var/www/lisausa/shared/bundle/jruby/1.9/gems/activerecord-jdbc-adapter-1.1.1/lib/arjdbc/jdbc/adapter.rb:183:in `execute'
/var/www/lisausa/shared/bundle/jruby/1.9/gems/activerecord-jdbc-adapter-1.1.1/lib/arjdbc/jdbc/adapter.rb:275:in `select'
/var/www/lisausa/shared/bundle/jruby/1.9/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all'
/var/www/lisausa/shared/bundle/jruby/1.9/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/query_cache.rb:56:in `select_all'
/var/www/lisausa/shared/bundle/jruby/1.9/gems/activerecord-3.0.10/lib/active_record/base.rb:473:in `find_by_sql'
/var/www/lisausa/shared/bundle/jruby/1.9/gems/activerecord-3.0.10/lib/active_record/relation.rb:64:in `to_a'
/var/www/lisausa/shared/bundle/jruby/1.9/gems/activerecord-3.0.10/lib/active_record/relation/finder_methods.rb:143:in `all'

Fog の代わりに ruby​​-cloudfiles gem を使用してみましたが、最終的にはその組み合わせを使用してもまったく同じエラーが発生するようです。このファイルのダウンロード/クラウドファイルのアップロード部分を無効にすると、これらのエラーは表示されず、この特定のジョブを数日間実行したままにすることができました.

ここで何が起こっているのかについての理論はありますか?

4

1 に答える 1

0

それが価値があることについては、数ヶ月後、私はあなたにそれを言うことができます

「ActiveRecord::JDBCError:サーバーからの応答を読み取ることができません。接続が予期せず失われる前に、4バイトを読み取る必要があり、0バイトを読み取る必要があります...」

通常、データベース接続が切断され(ネットワークの問題、DBがダウンしたなどの理由で)、基になるソケットが閉じられたことを示しています。少なくとも私たちにとって、JRuby / ActiveRecord / ConnectionPoolのデフォルトの動作は、再接続するのではなく、すべてのコマンドでこのエラーが発生し続けることです。

于 2012-04-26T15:32:53.540 に答える