Commit b8fb8761 authored by Ash McKenzie's avatar Ash McKenzie

Merge branch 'fix_disable_prepared_statements_clobbering_pool_size' into 'master'

Fix disable_prepared_statements clobbering pool size

See merge request gitlab-org/gitlab!66988
parents ea1185e2 7f674389
......@@ -34,9 +34,12 @@ module Gitlab
Gitlab::Runtime.max_threads + headroom
end
def uncached_config
scope.connection_db_config.configuration_hash.with_indifferent_access
end
def config
@config ||=
scope.connection_db_config.configuration_hash.with_indifferent_access
@config ||= uncached_config
end
def pool_size
......@@ -69,7 +72,7 @@ module Gitlab
# Disables prepared statements for the current database connection.
def disable_prepared_statements
scope.establish_connection(config.merge(prepared_statements: false))
scope.establish_connection(uncached_config.merge(prepared_statements: false))
end
def read_only?
......
......@@ -140,6 +140,19 @@ RSpec.describe Gitlab::Database::Connection do
expect(connection.scope.connection.prepared_statements).to eq(false)
end
context 'with dynamic connection pool size' do
before do
connection.scope.establish_connection(connection.config.merge(pool: 7))
end
it 'retains the set pool size' do
connection.disable_prepared_statements
expect(connection.scope.connection.prepared_statements).to eq(false)
expect(connection.scope.connection.pool.size).to eq(7)
end
end
end
describe '#read_only?' do
......
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