SharedConnectionPool - NoMethodError: undefined method 'site' for Integer (#37374)

This commit is contained in:
Shlee 2026-01-09 23:20:50 +07:00 committed by Claire
parent f354bbe8aa
commit 1eb8d1b967

View file

@ -41,12 +41,17 @@ class ConnectionPool::SharedConnectionPool < ConnectionPool
# ConnectionPool 2.4+ calls `checkin(force: true)` after fork. # ConnectionPool 2.4+ calls `checkin(force: true)` after fork.
# When this happens, we should remove all connections from Thread.current # When this happens, we should remove all connections from Thread.current
::Thread.current.keys.each do |name| # rubocop:disable Style/HashEachMethods connection_keys = ::Thread.current.keys.select { |key| key.to_s.start_with?("#{@key}-") && !key.to_s.start_with?("#{@key_count}-") }
next unless name.to_s.start_with?("#{@key}-") count_keys = ::Thread.current.keys.select { |key| key.to_s.start_with?("#{@key_count}-") }
@available.push(::Thread.current[name]) connection_keys.each do |key|
::Thread.current[name] = nil @available.push(::Thread.current[key])
::Thread.current[key] = nil
end end
count_keys.each do |key|
::Thread.current[key] = nil
end
elsif ::Thread.current[key(preferred_tag)] elsif ::Thread.current[key(preferred_tag)]
if ::Thread.current[key_count(preferred_tag)] == 1 if ::Thread.current[key_count(preferred_tag)] == 1
@available.push(::Thread.current[key(preferred_tag)]) @available.push(::Thread.current[key(preferred_tag)])