Commit b657e31f authored by Luke Duncalfe's avatar Luke Duncalfe

Merge branch 'create_connection_pool_rails_61' into 'master'

Use ConnectionHandler class to establish connection

This is for forward compat with Rails 6.1: 
`ActiveRecord::ConnectionAdapters::ConnectionSpecification::Resolver` 
no longer exists in Rails 6.1

Related issue: 
https://gitlab.com/gitlab-org/gitlab/-/issues/329572

See merge request gitlab-org/gitlab!61323
parents 29c0e30f daf4767f
......@@ -243,23 +243,13 @@ module Gitlab
# pool_size - The size of the DB pool.
# host - An optional host name to use instead of the default one.
def self.create_connection_pool(pool_size, host = nil, port = nil)
env = Rails.env
original_config = ActiveRecord::Base.configurations.to_h
original_config = Gitlab::Database.config
env_config = original_config[env].with_indifferent_access.merge(pool: pool_size)
env_config = original_config.merge(pool: pool_size)
env_config[:host] = host if host
env_config[:port] = port if port
config = ActiveRecord::DatabaseConfigurations.new(
original_config.merge(env => env_config)
)
spec =
ActiveRecord::
ConnectionAdapters::
ConnectionSpecification::Resolver.new(config).spec(env.to_sym)
ActiveRecord::ConnectionAdapters::ConnectionPool.new(spec)
ActiveRecord::ConnectionAdapters::ConnectionHandler.new.establish_connection(env_config)
end
def self.connection
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment