我无法确定在我编写的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 gem 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有一些长时间延迟的事情,尽管如此,我再也无法手动重现我可以用手动查询等判断的可见超时。 / p>
关于这个问题的任何想法,关于为什么时间会继续发生,或者更具体地说,如何通过提供Sequel
适当的设置(或许我有一个格式错误的arg列表)或修改MySQL的{{1}来解决它对于这种情况?
答案 0 :(得分:1)
Sequel jdbc适配器将连接字符串直接传递给JDBC,它不解析嵌入式选项。你需要这样做:
DB = Sequel.connect("jdbc:mysql://localhost/project_db?user=USERNAME&password=PASSWD", :max_connections=>10, :pool_timeout=>120)