diff --git a/CHANGELOG b/CHANGELOG index cf1f62e1f..cf56885be 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +=== master + +* Switch default connection pool to timed_queue on Ruby 3.2+ (jeremyevans) + === 5.84.0 (2024-09-01) * Support creating VIRTUAL tables on SQLite via the create_table :using option (jeremyevans) diff --git a/lib/sequel/connection_pool.rb b/lib/sequel/connection_pool.rb index 52f047518..6940eef9f 100644 --- a/lib/sequel/connection_pool.rb +++ b/lib/sequel/connection_pool.rb @@ -70,13 +70,13 @@ def connection_pool_class(opts) else pc = if opts[:single_threaded] opts[:servers] ? :sharded_single : :single - # :nocov: - elsif RUBY_VERSION >= '3.4' # SEQUEL6 or maybe earlier switch to 3.2 + elsif RUBY_VERSION >= '3.2' opts[:servers] ? :sharded_timed_queue : :timed_queue # :nocov: else opts[:servers] ? :sharded_threaded : :threaded end + # :nocov: connection_pool_class(:pool_class=>pc) end diff --git a/spec/core/connection_pool_spec.rb b/spec/core/connection_pool_spec.rb index 0ace412d6..96ab1daa7 100644 --- a/spec/core/connection_pool_spec.rb +++ b/spec/core/connection_pool_spec.rb @@ -1271,12 +1271,12 @@ def @pool.acquire(_,_=nil) raise Sequel::DatabaseDisconnectError; end Sequel::ConnectionPool.send(:get_pool, db, :single_threaded=>true, :servers=>{}).pool_type.must_equal :sharded_single end - it "should default to :single without :single_threaded or :servers" do - Sequel::ConnectionPool.send(:get_pool, db, {}).pool_type.must_equal(RUBY_VERSION >= '3.4' ? :timed_queue : :threaded) + it "should default to :timed_queue/:threaded without :single_threaded or :servers" do + Sequel::ConnectionPool.send(:get_pool, db, {}).pool_type.must_equal(RUBY_VERSION >= '3.2' ? :timed_queue : :threaded) end - it "should default to :single without :single_threaded with :servers" do - Sequel::ConnectionPool.send(:get_pool, db, :servers=>{}).pool_type.must_equal(RUBY_VERSION >= '3.4' ? :sharded_timed_queue : :sharded_threaded) + it "should default to :sharded_timed_queue/:sharded_threaded without :single_threaded with :servers" do + Sequel::ConnectionPool.send(:get_pool, db, :servers=>{}).pool_type.must_equal(RUBY_VERSION >= '3.2' ? :sharded_timed_queue : :sharded_threaded) end end unless ENV['SEQUEL_DEFAULT_CONNECTION_POOL']