0

我无法确定以下Sequel::PoolTimeout错误的原因来自我编写的 Ruby 脚本:

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的说明,我尝试将限制提高如下:pool_timeout

DB = Sequel.connect("jdbc:mysql://localhost/project_db?user=USERNAME&password=PASSWD&max_connections=10&pool_timeout=120")

似乎max_connectionsandpool_timeout可能无法识别,但是我没有看到任何其他方式将这些参数传递到连接中。

这里有问题的实际代码是: if DB[:products].where(url: url.to_s).empty?

我已经看到代码工作得很好一点点,但没有失败,它要么立即失败,要么在几分钟后失败,而就它发生的时间而言没有任何可重现性。我开始怀疑这是 MySQL 配置问题或导致localhostDBMS 有一些长时间延迟的原因,尽管我无法手动重现可以通过手动查询等来判断的可见超时。

关于这个问题的任何想法,关于为什么会继续发生,或者更具体地说,如何通过提供Sequel正确的设置(也许我有一个格式错误的 arg 列表)或/etc/my.cnf针对这种情况修改 MySQL 来解决它?

4

1 回答 1

1

Sequel jdbc 适配器将连接字符串直接传递给 JDBC,它不会解析嵌入式选项。你需要做:

DB = Sequel.connect("jdbc:mysql://localhost/project_db?user=USERNAME&password=PASSWD", :max_connections=>10, :pool_timeout=>120)

于 2013-09-16T19:16:51.220 回答