我一直无法确定我编写的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我用核磁共振和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可能无法识别,但是我没有看到任何其他方法将这些参数传递到连接中。
这里讨论的实际代码是:if DB[:products].where(url: url.to_s).empty?
我已经看到代码在一小段时间内工作得很好,但毫无疑问,它要么立即失败,要么在几分钟后失败,并且没有任何重现性。我开始怀疑这是MySQL配置问题还是什么导致localhost数据库管理系统有一些长时间的延迟,尽管,同样,我不能手动重现可见的超时,我可以通过手动查询来判断,等等。
关于为什么超时会一直发生,或者更具体地说,如何通过提供正确的Sequel设置(可能我有一个格式错误的arg列表)或针对这种情况修改MySQL的/etc/my.cnf,有什么想法吗?
发布于 2013-09-17 03:16:51
Sequel jdbc适配器将连接字符串直接传递给JDBC,它不会解析出嵌入的选项。您需要做的是:
DB = Sequel.connect("jdbc:mysql://localhost/project_db?user=USERNAME&password=PASSWD", :max_connections=>10, :pool_timeout=>120)
https://stackoverflow.com/questions/18774259
复制相似问题