0

I have been unable to determine what the cause of the following Sequel::PoolTimeout error is coming from in a Ruby script I have written:

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

I have tried this with both MRI and JRuby with exactly the same results.

As per the instructions on the Sequel gem here, I have attempted to raise the pool_timeout limit as follows:

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

It seems as though the max_connections and pool_timeout may not be recognized, however I'm not seeing any other way to pass these args on into the connection.

The actual code that is in question here is: if DB[:products].where(url: url.to_s).empty?

I have seen the code work just fine for a little bit, but without fail it fails either right away or after a couple minutes without any reproducibility in terms of when it occurs. I am starting to suspect that this is a MySQL config issue or something causing the localhost DBMS to have some prolonged delays, although, again, I cannot manually reproduce a visible timeout that I can tell with manual queries, etc.

Any ideas on this issue as to why the timout would keep happening or, more particularly, how to resolve it either via feeding Sequel proper settings (perhaps I have a malformed arg list) or modifying MySQL's /etc/my.cnf for such a scenario?

ylluminate
  • 12,102
  • 17
  • 78
  • 152

1 Answers1

1

The Sequel jdbc adapter passes the connection string directly to JDBC, it doesn't parse out embedded options. You need to do:

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

Jeremy Evans
  • 11,959
  • 27
  • 26