gpt4 book ai didi

mysql - Jruby/Resque : Network connections from resque job begin failing repeatedly

转载 作者:行者123 更新时间:2023-11-30 23:35:59 25 4
gpt4 key购买 nike

我在 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'

我尝试使用 ruby​​-cloudfiles gem 而不是 Fog,但我们似乎开始遇到完全相同的错误,最终也使用该组合。如果我禁用其中的文件下载/cloudfiles 上传部分,这些错误将永远不会出现,并且我已经能够让这个特定的作业运行数天。

关于这里可能发生的事情有什么理论吗?

最佳答案

不管怎样,几个月后,我可以告诉你

“ActiveRecord::JDBCError:无法从服务器读取响应。预期读取 4 个字节,但在连接意外丢失之前读取了 0 个字节...”

通常是我们的一个指示器,表明数据库连接已断开(由于网络问题或数据库出现故障等)并且底层套接字已关闭。至少对我们来说,JRuby/ActiveRecord/ConnectionPool 的默认行为是在每个命令上都出现此错误,而不是重新连接。

关于mysql - Jruby/Resque : Network connections from resque job begin failing repeatedly,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7324365/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com