Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump sequel from 5.69.0 to 5.70.0 #498

Merged
merged 1 commit into from
Jul 3, 2023
Merged

Conversation

dependabot[bot]
Copy link
Contributor

@dependabot dependabot bot commented on behalf of github Jul 3, 2023

Bumps sequel from 5.69.0 to 5.70.0.

Changelog

Sourced from sequel's changelog.

=== 5.70.0 (2023-07-01)

  • Make static_cache plugin better handle cases where forbid_lazy_load plugin is already loaded (jeremyevans)

  • Fix ShardedThreadedConnectionPool#remove_server to disconnect all connections if removing multiple servers (jeremyevans)

  • Support SEQUEL_DEFAULT_CONNECTION_POOL environment variable for choosing connection pool when :pool_class Database option is not set (jeremyevans)

  • Add sharded_timed_queue connection pool (jeremyevans)

  • Make connection_{validator,expiration} and async_thread_pool extensions work with timed_queue connection pool (jeremyevans)

  • Make connection_{validator,expiration} extensions raise error when used with single threaded pools (HoneyryderChuck, jeremyevans) (#2049)

  • Workaround possible resource starvation in threaded connection pool (ioquatix) (#2048)

Commits
  • 318dece Bump version to 5.70.0
  • 0a5feda Add a spec for sharded timed queue preconnect when you cannot make a new conn...
  • f9f4eda Do not allow lazy loading for Database#first with integer argument in static_...
  • f473b7b Make static_cache plugin better handle cases where forbid_lazy_load plugin is...
  • af953ca Make SEQUEL_DEFAULT_CONNECTION_POOL environment variable handle sharding
  • f0916af Limit jdbc-sqlite3 version in CI
  • b85d631 Add sharded_timed_queue connection pool
  • 8b87432 Make synchronize_sql extension specs work with timed_queue connection pool
  • d9d2e8a Make connection_{validator,expiration} and async_thread_pool extensions work ...
  • acb8bca raise error when connection_validator is loaded in single threaded mode
  • Additional commits viewable in compare view

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

Bumps [sequel](https://github.com/jeremyevans/sequel) from 5.69.0 to 5.70.0.
- [Changelog](https://github.com/jeremyevans/sequel/blob/master/CHANGELOG)
- [Commits](jeremyevans/sequel@5.69.0...5.70.0)

---
updated-dependencies:
- dependency-name: sequel
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
@dependabot dependabot bot added dependencies ruby Pull requests that update Ruby code labels Jul 3, 2023
@github-actions
Copy link

github-actions bot commented Jul 3, 2023

@github-actions
Copy link

github-actions bot commented Jul 3, 2023

gem compare sequel 5.69.0 5.70.0

Compared versions: ["5.69.0", "5.70.0"]
  DIFFERENT date:
    5.69.0: 2023-06-01 00:00:00 UTC
    5.70.0: 2023-07-01 00:00:00 UTC
  DIFFERENT version:
    5.69.0: 5.69.0
    5.70.0: 5.70.0
  DIFFERENT files:
    5.69.0->5.70.0:
      * Added:
            doc/release_notes/5.70.0.txt +35/-0
            lib/sequel/connection_pool/sharded_timed_queue.rb +374/-0
      * Changed:
            CHANGELOG +16/-0
            lib/sequel/connection_pool.rb +8/-1
            lib/sequel/connection_pool/sharded_threaded.rb +11/-10
            lib/sequel/connection_pool/threaded.rb +6/-0
            lib/sequel/connection_pool/timed_queue.rb +16/-3
            lib/sequel/extensions/async_thread_pool.rb +3/-2
            lib/sequel/extensions/connection_expiration.rb +15/-9
            lib/sequel/extensions/connection_validator.rb +15/-10
            lib/sequel/extensions/server_block.rb +2/-1
            lib/sequel/plugins/static_cache.rb +38/-0
            lib/sequel/version.rb +1/-1
  DIFFERENT extra_rdoc_files:
    5.69.0->5.70.0:
      * Added:
            doc/release_notes/5.70.0.txt +35/-0
      * Changed:
            CHANGELOG +16/-0

@github-actions
Copy link

github-actions bot commented Jul 3, 2023

gem compare --diff sequel 5.69.0 5.70.0

Compared versions: ["5.69.0", "5.70.0"]
  DIFFERENT files:
    5.69.0->5.70.0:
      * Added:
        doc/release_notes/5.70.0.txt
                --- /tmp/20230703-2114-qj28rq	2023-07-03 02:31:32.689642486 +0000
                +++ /tmp/d20230703-2114-p26aer/sequel-5.70.0/doc/release_notes/5.70.0.txt	2023-07-03 02:31:32.489640522 +0000
                @@ -0,0 +1,35 @@
                += New Features
                +
                +* A sharded_timed_queue connection pool has been added. This offers
                +  most of the same features as the sharded_threaded connection pool,
                +  but uses the new Queue#pop :timeout features added in Ruby 3.2 to
                +  allow for a simpler and possibly faster and more robust
                +  implementation.
                +
                +* If a :pool_class option is not specified when creating a Database,
                +  Sequel will now look at the SEQUEL_DEFAULT_CONNECTION_POOL
                +  environment variable to determine the connection pool class to use.
                +  This allows you to set SEQUEL_DEFAULT_CONNECTION_POOL=timed_queue
                +  on Ruby 3.2 to test with the timed_queue connection pool without
                +  making any code changes.  If the :servers Database option is given,
                +  Sequel will automatically use the sharded version of the connection
                +  pool specified by SEQUEL_DEFAULT_CONNECTION_POOL.
                +
                += Other Improvements
                +
                +* The connection_validator, connection_expiration, and
                +  async_thread_pool extensions now work with the timed_queue and
                +  sharded_timed_queue connection pools.
                +
                +* The sharded_threaded connection pool now disconnects connections
                +  for all specified servers instead of just the last specified server
                +  when using remove_server.
                +
                +* The static_cache plugin now recognizes when the forbid_lazy_load
                +  plugin is already loaded, and does not return instances that
                +  forbid lazy load for methods that return a single object, such as
                +  Database.{[],cache_get_pk,first}.
                +
                +* Sequel now displays an informative error message if attempting to
                +  load the connection_validator or connection_expiration extensions
                +  when using the single threaded connection pool.
        lib/sequel/connection_pool/sharded_timed_queue.rb
                --- /tmp/20230703-2114-6vu2mr	2023-07-03 02:31:32.693642525 +0000
                +++ /tmp/d20230703-2114-p26aer/sequel-5.70.0/lib/sequel/connection_pool/sharded_timed_queue.rb	2023-07-03 02:31:32.581641425 +0000
                @@ -0,0 +1,374 @@
                +# frozen-string-literal: true
                +
                +# :nocov:
                +raise LoadError, "Sequel::ShardedTimedQueueConnectionPool is only available on Ruby 3.2+" unless RUBY_VERSION >= '3.2'
                +# :nocov:
                +
                +# A connection pool allowing multi-threaded access to a sharded pool of connections,
                +# using a timed queue (only available in Ruby 3.2+).
                +class Sequel::ShardedTimedQueueConnectionPool < Sequel::ConnectionPool
                +  # The maximum number of connections this pool will create per shard.
                +  attr_reader :max_size
                +
                +  # The following additional options are respected:
                +  # :max_connections :: The maximum number of connections the connection pool
                +  #                     will open (default 4)
                +  # :pool_timeout :: The amount of seconds to wait to acquire a connection
                +  #                  before raising a PoolTimeout (default 5)
                +  # :servers :: A hash of servers to use.  Keys should be symbols.  If not
                +  #             present, will use a single :default server.
                +  # :servers_hash :: The base hash to use for the servers.  By default,
                +  #                  Sequel uses Hash.new(:default).  You can use a hash with a default proc
                +  #                  that raises an error if you want to catch all cases where a nonexistent
                +  #                  server is used.
                +  def initialize(db, opts = OPTS)
                +    super
                +
                +    @max_size = Integer(opts[:max_connections] || 4)
                +    raise(Sequel::Error, ':max_connections must be positive') if @max_size < 1
                +    @mutex = Mutex.new  
                +    @timeout = Float(opts[:pool_timeout] || 5)
                +
                +    @allocated = {}
                +    @sizes = {}
                +    @queues = {}
                +    @servers = opts.fetch(:servers_hash, Hash.new(:default))
                +
                +    add_servers([:default])
                +    add_servers(opts[:servers].keys) if opts[:servers]
                +  end
                +
                +  # Adds new servers to the connection pool.  Allows for dynamic expansion of the potential replicas/shards
                +  # at runtime. +servers+ argument should be an array of symbols. 
                +  def add_servers(servers)
                +    sync do
                +      servers.each do |server|
                +        next if @servers.has_key?(server)
                +
                +        @servers[server] = server
                +        @sizes[server] = 0
                +        @queues[server] = Queue.new
                +        (@allocated[server] = {}).compare_by_identity
                +      end
                +    end
                +    nil
                +  end
                +  
                +  # Yield all of the available connections, and the one currently allocated to
                +  # this thread (if one is allocated).  This will not yield connections currently
                +  # allocated to other threads, as it is not safe to operate on them.
                +  def all_connections
                +    thread = Sequel.current
                +    sync{@queues.to_a}.each do |server, queue|
                +      if conn = owned_connection(thread, server)
                +        yield conn
                +      end
                +
                +      # Use a hash to record all connections already seen.  As soon as we
                +      # come across a connection we've already seen, we stop the loop.
                +      conns = {}
                +      conns.compare_by_identity
                +      while true
                +        conn = nil
                +        begin
                +          break unless (conn = queue.pop(timeout: 0)) && !conns[conn]
                +          conns[conn] = true
                +          yield conn
                +        ensure
                +          queue.push(conn) if conn
                +        end
                +      end
                +    end
                +
                +    nil
                +  end
                +  
                +  # Removes all connections currently in the pool's queue. This method has the effect of 
                +  # disconnecting from the database, assuming that no connections are currently
                +  # being used.
                +  # 
                +  # Once a connection is requested using #hold, the connection pool
                +  # creates new connections to the database.
                +  #
                +  # If the :server option is provided, it should be a symbol or array of symbols,
                +  # and then the method will only disconnect connectsion from those specified shards.
                +  def disconnect(opts=OPTS)
                +    (opts[:server] ? Array(opts[:server]) : sync{@servers.keys}).each do |server|
                +      raise Sequel::Error, "invalid server" unless queue = sync{@queues[server]}
                +      while conn = queue.pop(timeout: 0)
                +        disconnect_pool_connection(conn, server)
                +      end
                +      fill_queue(server)
                +    end
                +    nil
                +  end
                +
                +  # Chooses the first available connection for the given server, or if none are
                +  # available, creates a new connection.  Passes the connection to the supplied
                +  # block:
                +  # 
                +  #   pool.hold(:server1) {|conn| conn.execute('DROP TABLE posts')}
                +  # 
                +  # Pool#hold is re-entrant, meaning it can be called recursively in
                +  # the same thread without blocking.
                +  #
                +  # If no connection is immediately available and the pool is already using the maximum
                +  # number of connections, Pool#hold will block until a connection
                +  # is available or the timeout expires.  If the timeout expires before a
                +  # connection can be acquired, a Sequel::PoolTimeout is raised.
                +  def hold(server=:default)
                +    server = pick_server(server)
                +    t = Sequel.current
                +    if conn = owned_connection(t, server)
                +      return yield(conn)
                +    end
                +
                +    begin
                +      conn = acquire(t, server)
                +      yield conn
                +    rescue Sequel::DatabaseDisconnectError, *@error_classes => e
                +      if disconnect_error?(e)
                +        oconn = conn
                +        conn = nil
                +        disconnect_pool_connection(oconn, server) if oconn
                +        sync{@allocated[server].delete(t)}
                +        fill_queue(server)
                +      end
                +      raise
                +    ensure
                +      release(t, conn, server) if conn
                +    end
                +  end
                +
                +  # The total number of connections in the pool. Using a non-existant server will return nil.
                +  def size(server=:default)
                +    sync{@sizes[server]}
                +  end
                +  
                +  # Remove servers from the connection pool. Similar to disconnecting from all given servers,
                +  # except that after it is used, future requests for the servers will use the
                +  # :default server instead.
                +  #
                +  # Note that an error will be raised if there are any connections currently checked
                +  # out for the given servers.
                +  def remove_servers(servers)
                +    conns = []
                +    raise(Sequel::Error, "cannot remove default server") if servers.include?(:default)
                +
                +    sync do
                +      servers.each do |server|
                +        next unless @servers.has_key?(server)
                +
                +        queue = @queues[server]
                +
                +        while conn = queue.pop(timeout: 0)
                +          @sizes[server] -= 1
                +          conns << conn
                +        end
                +
                +        unless @sizes[server] == 0
                +          raise Sequel::Error, "cannot remove server #{server} as it has allocated connections"
                +        end
                +
                +        @servers.delete(server)
                +        @sizes.delete(server)
                +        @queues.delete(server)
                +        @allocated.delete(server)
                +      end
                +    end
                +
                +    nil
                +  ensure
                +    disconnect_connections(conns)
                +  end
                +
                +  # Return an array of symbols for servers in the connection pool.
                +  def servers
                +    sync{@servers.keys}
                +  end
                +
                +  def pool_type
                +    :sharded_timed_queue
                +  end
                +  
                +  private
                +
                +  # Create a new connection, after the pool's current size has already
                +  # been updated to account for the new connection.  If there is an exception
                +  # when creating the connection, decrement the current size.
                +  #
                +  # This should only be called after can_make_new?.  If there is an exception
                +  # between when can_make_new? is called and when preallocated_make_new
                +  # is called, it has the effect of reducing the maximum size of the
                +  # connection pool by 1, since the current size of the pool will show a
                +  # higher number than the number of connections allocated or
                +  # in the queue.
                +  #
                +  # Calling code should not have the mutex when calling this.
                +  def preallocated_make_new(server)
                +    make_new(server)
                +  rescue Exception
                +    sync{@sizes[server] -= 1}
                +    raise
                +  end
                +
                +  # Disconnect all available connections immediately, and schedule currently allocated connections for disconnection
                +  # as soon as they are returned to the pool. The calling code should NOT
                +  # have the mutex before calling this.
                +  def disconnect_connections(conns)
                +    conns.each{|conn| disconnect_connection(conn)}
                +  end
                +
                +  # Decrement the current size of the pool for the server when disconnecting connections.
                +  #
                +  # Calling code should not have the mutex when calling this.
                +  def disconnect_pool_connection(conn, server)
                +    sync{@sizes[server] -= 1}
                +    disconnect_connection(conn)
                +  end
                +
                +  # If there are any threads waiting on the queue, try to create
                +  # new connections in a separate thread if the pool is not yet at the
                +  # maximum size.
                +  #
                +  # The reason for this method is to handle cases where acquire
                +  # could not retrieve a connection immediately, and the pool
                +  # was already at the maximum size.  In that case, the acquire will
                +  # wait on the queue until the timeout.  This method is called
                +  # after disconnecting to potentially add new connections to the
                +  # pool, so the threads that are currently waiting for connections
                +  # do not timeout after the pool is no longer full.
                +  def fill_queue(server)
                +    queue = sync{@queues[server]}
                +    if queue.num_waiting > 0
                +      Thread.new do
                +        while queue.num_waiting > 0 && (conn = try_make_new(server))
                +          queue.push(conn)
                +        end
                +      end
                +    end
                +  end
                +
                +  # Whether the given size is less than the maximum size of the pool.
                +  # In that case, the pool's current size is incremented.  If this
                +  # method returns true, space in the pool for the connection is
                +  # preallocated, and preallocated_make_new should be called to
                +  # create the connection.
                +  #
                +  # Calling code should have the mutex when calling this.
                +  def can_make_new?(server, current_size)
                +    if @max_size > current_size
                +      @sizes[server] += 1
                +    end
                +  end
                +
                +  # Try to make a new connection if there is space in the pool.
                +  # If the pool is already full, look for dead threads/fibers and
                +  # disconnect the related connections.
                +  #
                +  # Calling code should not have the mutex when calling this.
                +  def try_make_new(server)
                +    return preallocated_make_new(server) if sync{can_make_new?(server, @sizes[server])}
                +
                +    to_disconnect = nil
                +    do_make_new = false
                +
                +    sync do
                +      current_size = @sizes[server]
                +      alloc = @allocated[server]
                +      alloc.keys.each do |t|
                +        unless t.alive?
                +          (to_disconnect ||= []) << alloc.delete(t)
                +          current_size -= 1
                +        end
                +      end
                +    
                +      do_make_new = true if can_make_new?(server, current_size)
                +    end
                +
                +    begin
                +      preallocated_make_new(server) if do_make_new
                +    ensure
                +      if to_disconnect
                +        to_disconnect.each{|conn| disconnect_pool_connection(conn, server)}
                +        fill_queue(server)
                +      end
                +    end
                +  end
                +  
                +  # Assigns a connection to the supplied thread, if one
                +  # is available.
                +  #
                +  # This should return a connection if one is available within the timeout,
                +  # or raise PoolTimeout if a connection could not be acquired within the timeout.
                +  #
                +  # Calling code should not have the mutex when calling this.
                +  def acquire(thread, server)
                +    queue = sync{@queues[server]}
                +    if conn = queue.pop(timeout: 0) || try_make_new(server) || queue.pop(timeout: @timeout)
                +      sync{@allocated[server][thread] = conn}
                +    else
                +      name = db.opts[:name]
                +      raise ::Sequel::PoolTimeout, "timeout: #{@timeout}, server: #{server}#{", database name: #{name}" if name}"
                +    end
                +  end
                +
                +  # Returns the connection owned by the supplied thread for the given server,
                +  # if any. The calling code should NOT already have the mutex before calling this.
                +  def owned_connection(thread, server)
                +    sync{@allocated[server][thread]}
                +  end
                +
                +  # If the server given is in the hash, return it, otherwise, return the default server.
                +  def pick_server(server)
                +    sync{@servers[server]}
                +  end
                +  
                +  # Create the maximum number of connections immediately. This should not be called
                +  # with a true argument unless no code is currently operating on the database.
                +  #
                +  # Calling code should not have the mutex when calling this.
                +  def preconnect(concurrent = false)
                +    conn_servers = sync{@servers.keys}.map!{|s| Array.new(@max_size - @sizes[s], s)}.flatten!
                +
                +    if concurrent
                +      conn_servers.map! do |server|
                +        queue = sync{@queues[server]}
                +        Thread.new do 
                +          if conn = try_make_new(server)
                +            queue.push(conn)
                +          end
                +        end
                +      end.each(&:value)
                +    else
                +      conn_servers.each do |server|
                +        if conn = try_make_new(server)
                +          sync{@queues[server]}.push(conn)
                +        end
                +      end
                +    end
                +
                +    nil
                +  end
                +
                +  # Releases the connection assigned to the supplied thread back to the pool.
                +  #
                +  # Calling code should not have the mutex when calling this.
                +  def release(thread, _, server)
                +    checkin_connection(sync{@allocated[server].delete(thread)}, server)
                +    nil
                +  end
                +
                +  # Adds a connection to the queue of available connections, returns the connection.
                +  def checkin_connection(conn, server)
                +    sync{@queues[server]}.push(conn)
                +    conn
                +  end
                +
                +  # Yield to the block while inside the mutex.
                +  #
                +  # Calling code should not have the mutex when calling this.
                +  def sync
                +    @mutex.synchronize{yield}
                +  end
                +end
      * Changed:
        CHANGELOG
                --- /tmp/d20230703-2114-p26aer/sequel-5.69.0/CHANGELOG	2023-07-03 02:31:32.297638636 +0000
                +++ /tmp/d20230703-2114-p26aer/sequel-5.70.0/CHANGELOG	2023-07-03 02:31:32.477640404 +0000
                @@ -0,0 +1,16 @@
                +=== 5.70.0 (2023-07-01)
                +
                +* Make static_cache plugin better handle cases where forbid_lazy_load plugin is already loaded (jeremyevans)
                +
                +* Fix ShardedThreadedConnectionPool#remove_server to disconnect all connections if removing multiple servers (jeremyevans)
                +
                +* Support SEQUEL_DEFAULT_CONNECTION_POOL environment variable for choosing connection pool when :pool_class Database option is not set (jeremyevans)
                +
                +* Add sharded_timed_queue connection pool (jeremyevans)
                +
                +* Make connection_{validator,expiration} and async_thread_pool extensions work with timed_queue connection pool (jeremyevans)
                +
                +* Make connection_{validator,expiration} extensions raise error when used with single threaded pools (HoneyryderChuck, jeremyevans) (#2049)
                +
                +* Workaround possible resource starvation in threaded connection pool (ioquatix) (#2048)
                +
        lib/sequel/connection_pool.rb
                --- /tmp/d20230703-2114-p26aer/sequel-5.69.0/lib/sequel/connection_pool.rb	2023-07-03 02:31:32.321638872 +0000
                +++ /tmp/d20230703-2114-p26aer/sequel-5.70.0/lib/sequel/connection_pool.rb	2023-07-03 02:31:32.581641425 +0000
                @@ -34,0 +35 @@
                +    :sharded_timed_queue => :ShardedTimedQueueConnectionPool,
                @@ -45 +46,2 @@
                -    # <tt>:single_threaded</tt> and <tt>:servers</tt> options.
                +    # +SEQUEL_DEFAULT_CONNECTION_POOL+ environment variable if set, or
                +    # the <tt>:single_threaded</tt> and <tt>:servers</tt> options, otherwise.
                @@ -64,0 +67,3 @@
                +      elsif pc = ENV['SEQUEL_DEFAULT_CONNECTION_POOL']
                +        pc = "sharded_#{pc}" if opts[:servers] && !pc.start_with?('sharded_')
                +        connection_pool_class(:pool_class=>pc)
                @@ -67,0 +73,2 @@
                +        #elsif RUBY_VERSION >= '3.2' # SEQUEL6 or maybe earlier
                +        #  opts[:servers] ? :sharded_timed_queue : :timed_queue
        lib/sequel/connection_pool/sharded_threaded.rb
                --- /tmp/d20230703-2114-p26aer/sequel-5.69.0/lib/sequel/connection_pool/sharded_threaded.rb	2023-07-03 02:31:32.321638872 +0000
                +++ /tmp/d20230703-2114-p26aer/sequel-5.70.0/lib/sequel/connection_pool/sharded_threaded.rb	2023-07-03 02:31:32.581641425 +0000
                @@ -5 +5 @@
                -# The slowest and most advanced connection, dealing with both multi-threaded
                +# The slowest and most advanced connection pool, dealing with both multi-threaded
                @@ -115 +115 @@
                -  #   pool.hold {|conn| conn.execute('DROP TABLE posts')}
                +  #   pool.hold(:server1) {|conn| conn.execute('DROP TABLE posts')}
                @@ -148 +148,3 @@
                -    conns = nil
                +    conns = []
                +    raise(Sequel::Error, "cannot remove default server") if servers.include?(:default)
                +
                @@ -150 +151,0 @@
                -      raise(Sequel::Error, "cannot remove default server") if servers.include?(:default)
                @@ -153 +154 @@
                -          conns = disconnect_server_connections(server)
                +          conns.concat(disconnect_server_connections(server))
                @@ -162,3 +163,3 @@
                -    if conns
                -      disconnect_connections(conns)
                -    end
                +    nil
                +  ensure
                +    disconnect_connections(conns)
                @@ -189 +190 @@
                -  # This should return a connection is one is available within the timeout,
                +  # This should return a connection if one is available within the timeout,
                @@ -328 +329 @@
                -    conn_servers = @servers.keys.map!{|s| Array.new(max_size - _size(s), s)}.flatten!
                +    conn_servers = sync{@servers.keys}.map!{|s| Array.new(max_size - _size(s), s)}.flatten!
        lib/sequel/connection_pool/threaded.rb
                --- /tmp/d20230703-2114-p26aer/sequel-5.69.0/lib/sequel/connection_pool/threaded.rb	2023-07-03 02:31:32.321638872 +0000
                +++ /tmp/d20230703-2114-p26aer/sequel-5.70.0/lib/sequel/connection_pool/threaded.rb	2023-07-03 02:31:32.581641425 +0000
                @@ -276,0 +277,6 @@
                +    
                +    # Ensure that after signalling the condition, some other thread is given the
                +    # opportunity to acquire the mutex.
                +    # See <https://github.com/socketry/async/issues/99> for more context.
                +    sleep(0)
                +    
        lib/sequel/connection_pool/timed_queue.rb
                --- /tmp/d20230703-2114-p26aer/sequel-5.69.0/lib/sequel/connection_pool/timed_queue.rb	2023-07-03 02:31:32.321638872 +0000
                +++ /tmp/d20230703-2114-p26aer/sequel-5.70.0/lib/sequel/connection_pool/timed_queue.rb	2023-07-03 02:31:32.581641425 +0000
                @@ -84 +84 @@
                -    if conn = sync{@allocated[t]}
                +    if conn = owned_connection(t)
                @@ -225,0 +226,6 @@
                +  # Returns the connection owned by the supplied thread,
                +  # if any. The calling code should NOT already have the mutex before calling this.
                +  def owned_connection(thread)
                +    sync{@allocated[thread]}
                +  end
                +  
                @@ -227 +233 @@
                -  # with a true argument unles no code is currently operating on the database.
                +  # with a true argument unless no code is currently operating on the database.
                @@ -248 +254,8 @@
                -    @queue.push(sync{@allocated.delete(thread)})
                +    checkin_connection(sync{@allocated.delete(thread)})
                +    nil
                +  end
                +
                +  # Adds a connection to the queue of available connections, returns the connection.
                +  def checkin_connection(conn)
                +    @queue.push(conn)
                +    conn
        lib/sequel/extensions/async_thread_pool.rb
                --- /tmp/d20230703-2114-p26aer/sequel-5.69.0/lib/sequel/extensions/async_thread_pool.rb	2023-07-03 02:31:32.445640090 +0000
                +++ /tmp/d20230703-2114-p26aer/sequel-5.70.0/lib/sequel/extensions/async_thread_pool.rb	2023-07-03 02:31:32.653642132 +0000
                @@ -341,2 +341,3 @@
                -          unless pool.pool_type == :threaded || pool.pool_type == :sharded_threaded
                -            raise Error, "can only load async_thread_pool extension if using threaded or sharded_threaded connection pool"
                +          case pool.pool_type
                +          when :single, :sharded_single
                +            raise Error, "cannot load async_thread_pool extension if using single or sharded_single connection pool"
        lib/sequel/extensions/connection_expiration.rb
                --- /tmp/d20230703-2114-p26aer/sequel-5.69.0/lib/sequel/extensions/connection_expiration.rb	2023-07-03 02:31:32.445640090 +0000
                +++ /tmp/d20230703-2114-p26aer/sequel-5.70.0/lib/sequel/extensions/connection_expiration.rb	2023-07-03 02:31:32.653642132 +0000
                @@ -18,4 +18,3 @@
                -# Note that this extension only affects the default threaded
                -# and the sharded threaded connection pool.  The single
                -# threaded and sharded single threaded connection pools are
                -# not affected.  As the only reason to use the single threaded
                +# Note that this extension does not work with the single
                +# threaded and sharded single threaded connection pools.
                +# As the only reason to use the single threaded
                @@ -25,3 +24,4 @@
                -# threaded pools work fine even in single threaded code, so if
                -# you are currently using a single threaded pool and want to
                -# use this extension, switch to using a threaded pool.
                +# non-single threaded pools work fine even in single threaded
                +# code, so if you are currently using a single threaded pool
                +# and want to use this extension, switch to using another
                +# pool.
                @@ -47,0 +48,5 @@
                +      case pool.pool_type
                +      when :single, :sharded_single
                +        raise Error, "cannot load connection_expiration extension if using single or sharded_single connection pool"
                +      end
                +
                @@ -82,2 +87,3 @@
                -          if pool_type == :sharded_threaded
                -            sync{allocated(a.last).delete(Sequel.current)}
                +          case pool_type
                +          when :sharded_threaded, :sharded_timed_queue
                +            sync{@allocated[a.last].delete(Sequel.current)}
        lib/sequel/extensions/connection_validator.rb
                --- /tmp/d20230703-2114-p26aer/sequel-5.69.0/lib/sequel/extensions/connection_validator.rb	2023-07-03 02:31:32.445640090 +0000
                +++ /tmp/d20230703-2114-p26aer/sequel-5.70.0/lib/sequel/extensions/connection_validator.rb	2023-07-03 02:31:32.653642132 +0000
                @@ -37,4 +37,3 @@
                -# Note that this extension only affects the default threaded
                -# and the sharded threaded connection pool.  The single
                -# threaded and sharded single threaded connection pools are
                -# not affected.  As the only reason to use the single threaded
                +# Note that this extension does not work with the single
                +# threaded and sharded single threaded connection pools.
                +# As the only reason to use the single threaded
                @@ -44,3 +43,4 @@
                -# threaded pools work fine even in single threaded code, so if
                -# you are currently using a single threaded pool and want to
                -# use this extension, switch to using a threaded pool.
                +# non-single threaded pools work fine even in single threaded
                +# code, so if you are currently using a single threaded pool
                +# and want to use this extension, switch to using another
                +# pool.
                @@ -63,0 +64,5 @@
                +      case pool.pool_type
                +      when :single, :sharded_single
                +        raise Error, "cannot load connection_validator extension if using single or sharded_single connection pool"
                +      end
                +
                @@ -106,2 +111,3 @@
                -          if pool_type == :sharded_threaded
                -            sync{allocated(a.last).delete(Sequel.current)}
                +          case pool_type
                +          when :sharded_threaded, :sharded_timed_queue
                +            sync{@allocated[a.last].delete(Sequel.current)}
                @@ -123 +128,0 @@
                -
        lib/sequel/extensions/server_block.rb
                --- /tmp/d20230703-2114-p26aer/sequel-5.69.0/lib/sequel/extensions/server_block.rb	2023-07-03 02:31:32.453640168 +0000
                +++ /tmp/d20230703-2114-p26aer/sequel-5.70.0/lib/sequel/extensions/server_block.rb	2023-07-03 02:31:32.665642250 +0000
                @@ -72 +72,2 @@
                -      if defined?(ShardedThreadedConnectionPool) && pool.is_a?(ShardedThreadedConnectionPool)
                +      case pool.pool_type
                +      when :sharded_threaded, :sharded_timed_queue
        lib/sequel/plugins/static_cache.rb
                --- /tmp/d20230703-2114-p26aer/sequel-5.69.0/lib/sequel/plugins/static_cache.rb	2023-07-03 02:31:32.469640325 +0000
                +++ /tmp/d20230703-2114-p26aer/sequel-5.70.0/lib/sequel/plugins/static_cache.rb	2023-07-03 02:31:32.685642447 +0000
                @@ -66,0 +67,3 @@
                +          if @static_cache_frozen && defined?(::Sequel::Plugins::ForbidLazyLoad::ClassMethods) && is_a?(::Sequel::Plugins::ForbidLazyLoad::ClassMethods)
                +            extend ForbidLazyLoadClassMethods
                +          end
                @@ -244,0 +248,35 @@
                +          end
                +        end
                +      end
                +
                +      module ForbidLazyLoadClassMethods
                +        # Do not forbid lazy loading for single object retrieval.
                +        def cache_get_pk(pk)
                +          primary_key_lookup(pk)
                +        end
                +
                +        # Use static cache to return first arguments.
                +        def first(*args)
                +          if !defined?(yield) && args.empty?
                +            if o = @all.first
                +              _static_cache_frozen_copy(o)
                +            end
                +          else
                +            super
                +          end
                +        end
                +
                +        private
                +
                +        # Return a frozen copy of the object that does not have lazy loading
                +        # forbidden.
                +        def _static_cache_frozen_copy(o)
                +          o = call(Hash[o.values])
                +          o.errors.freeze
                +          o.freeze
                +        end
                +
                +        # Do not forbid lazy loading for single object retrieval.
                +        def primary_key_lookup(pk)
                +          if o = cache[pk]
                +            _static_cache_frozen_copy(o)
        lib/sequel/version.rb
                --- /tmp/d20230703-2114-p26aer/sequel-5.69.0/lib/sequel/version.rb	2023-07-03 02:31:32.473640365 +0000
                +++ /tmp/d20230703-2114-p26aer/sequel-5.70.0/lib/sequel/version.rb	2023-07-03 02:31:32.689642486 +0000
                @@ -9 +9 @@
                -  MINOR = 69
                +  MINOR = 70

@dentarg dentarg merged commit edb738d into main Jul 3, 2023
7 checks passed
@dentarg dentarg deleted the dependabot/bundler/sequel-5.70.0 branch July 3, 2023 04:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies ruby Pull requests that update Ruby code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant