我无法确定我编写的Ruby脚本中以下Sequel::PoolTimeout
错误的原因是什么:
Sequel::PoolTimeout: Sequel::PoolTimeout
hold at /Users/username/.rvm/gems/jruby-1.7.4@all/gems/sequel-4.2.0/lib/sequel/connection_pool/threaded.rb:100
hold at /Users/username/.rvm/gems/jruby-1.7.4@all/gems/sequel-4.2.0/lib/sequel/connection_pool/threaded.rb:93
synchronize at /Users/username/.rvm/gems/jruby-1.7.4@all/gems/sequel-4.2.0/lib/sequel/database/connecting.rb:234
execute at /Users/username/.rvm/gems/jruby-1.7.4@all/gems/sequel-4.2.0/lib/sequel/adapters/jdbc.rb:258
execute at /Users/username/.rvm/gems/jruby-1.7.4@all/gems/sequel-4.2.0/lib/sequel/dataset/actions.rb:793
fetch_rows at /Users/username/.rvm/gems/jruby-1.7.4@all/gems/sequel-4.2.0/lib/sequel/adapters/jdbc.rb:671
each at /Users/username/.rvm/gems/jruby-1.7.4@all/gems/sequel-4.2.0/lib/sequel/dataset/actions.rb:143
single_record at /Users/username/.rvm/gems/jruby-1.7.4@all/gems/sequel-4.2.0/lib/sequel/dataset/actions.rb:583
single_value at /Users/username/.rvm/gems/jruby-1.7.4@all/gems/sequel-4.2.0/lib/sequel/dataset/actions.rb:591
get at /Users/username/.rvm/gems/jruby-1.7.4@all/gems/sequel-4.2.0/lib/sequel/dataset/actions.rb:250
empty? at /Users/username/.rvm/gems/jruby-1.7.4@all/gems/sequel-4.2.0/lib/sequel/dataset/actions.rb:153
scrap at /Users/username/projectname/processers/get_category.rb:46
each at org/jruby/RubyArray.java:1617
each_with_index at org/jruby/RubyEnumerable.java:920
scrap at /Users/username/projectname/processers/get_category.rb:44
scrap at /Users/username/projectname/processers/get_category.rb:32
我已经使用MRI和JRuby尝试了完全相同的结果。
按照Sequel宝石here上的说明,我尝试如下提高
pool_timeout
限制:DB = Sequel.connect("jdbc:mysql://localhost/project_db?user=USERNAME&password=PASSWD&max_connections=10&pool_timeout=120")
似乎
max_connections
和pool_timeout
可能无法识别,但是我没有看到任何其他方法将这些args传递到连接中。这里有问题的实际代码是:
if DB[:products].where(url: url.to_s).empty?
我已经看到代码可以正常工作了一点,但是没有失败,它立即失败了,或者几分钟后就失败了,就发生时间而言没有任何可重复性。我开始怀疑这是MySQL配置问题,还是导致
localhost
DBMS延迟较长的原因,尽管同样,我无法手动重现可见的超时,我可以通过手动查询等告知超时。关于该问题为何会继续发生的任何想法,或更具体地说,如何通过提供
Sequel
正确的设置(也许我的arg列表格式错误)或针对这种情况修改MySQL的/etc/my.cnf
来解决它? 最佳答案
Sequel jdbc适配器将连接字符串直接传递给JDBC,它不解析嵌入式选项。您需要做:DB = Sequel.connect("jdbc:mysql://localhost/project_db?user=USERNAME&password=PASSWD", :max_connections=>10, :pool_timeout=>120)
关于mysql - 续集数据库连接池超时错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18774259/