Commit 0ad2e198 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'bvl-correct-thread-count' into 'master'

Correct threadcount in multithreaded environments

See merge request gitlab-org/gitlab!25261
parents bec1642c 65d112fa
---
title: Fix sidekiq jobs not always getting a database connection when running with low concurrency
merge_request: 25261
author:
type: fixed
......@@ -78,12 +78,16 @@ module Gitlab
end
def max_threads
main_thread = 1
if puma?
Puma.cli_config.options[:max_threads]
Puma.cli_config.options[:max_threads] + main_thread
elsif sidekiq?
Sidekiq.options[:concurrency]
# An extra thread for the poller in Sidekiq Cron:
# https://github.com/ondrejbartas/sidekiq-cron#under-the-hood
Sidekiq.options[:concurrency] + main_thread + 1
else
1
main_thread
end
end
end
......
......@@ -50,7 +50,7 @@ describe Gitlab::Runtime do
allow(puma_type).to receive_message_chain(:cli_config, :options).and_return(max_threads: 2)
end
it_behaves_like "valid runtime", :puma, 2
it_behaves_like "valid runtime", :puma, 3
end
context "unicorn" do
......@@ -71,7 +71,7 @@ describe Gitlab::Runtime do
allow(sidekiq_type).to receive(:options).and_return(concurrency: 2)
end
it_behaves_like "valid runtime", :sidekiq, 2
it_behaves_like "valid runtime", :sidekiq, 4
end
context "console" 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