Commit 03d106ed authored by Sean McGivern's avatar Sean McGivern

Merge branch 'bvl-db-pool-headroom' into 'master'

Allow adding headroom to the connection pool

See merge request gitlab-org/gitlab!34371
parents 3e69408e dfc5f228
......@@ -30,7 +30,7 @@ if Gitlab::Runtime.multi_threaded?
Rails.application.config.database_configuration[Rails.env]
previous_db_pool_size = db_config['pool']
db_config['pool'] = [db_config['pool'].to_i, max_threads].max
db_config['pool'] = [db_config['pool'].to_i, max_threads].max + ENV["DB_POOL_HEADROOM"].to_i
ActiveRecord::Base.establish_connection(db_config)
......
......@@ -48,6 +48,21 @@ describe 'Database config initializer' do
expect { subject }.not_to change { Gitlab::Database.config['pool'] }
end
end
context "when specifying headroom through an ENV variable" do
let(:headroom) { 10 }
before do
stub_database_config(pool_size: 1)
stub_env("DB_POOL_HEADROOM", headroom)
end
it "adds headroom on top of the calculated size" do
expect { subject }.to change { Gitlab::Database.config['pool'] }
.from(1)
.to(max_threads + headroom)
end
end
end
context "when using single-threaded runtime" 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