Commit c12b32b5 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'fix-sidekiq-scheduler-threads-db-connections' into 'master'

Wrap Sidekiq scheduler threads in Rails reloader

See merge request gitlab-org/gitlab!73716
parents 3c6e7845 7c2e4a6c
......@@ -116,3 +116,4 @@ Sidekiq.configure_client do |config|
end
Sidekiq::Client.prepend Gitlab::Patch::SidekiqClient
Sidekiq::Cron::Poller.prepend Gitlab::Patch::SidekiqCronPoller
# frozen_string_literal: true
module Gitlab
module Patch
module SidekiqCronPoller
def enqueue
Rails.application.reloader.wrap do
::Gitlab::WithRequestStore.with_request_store do
super
ensure
::Gitlab::Database::LoadBalancing.release_hosts
end
end
end
end
end
end
......@@ -14,11 +14,18 @@ module Gitlab
LUA_ZPOPBYSCORE_SHA = Digest::SHA1.hexdigest(LUA_ZPOPBYSCORE)
def enqueue_jobs(now = Time.now.to_f.to_s, sorted_sets = Sidekiq::Scheduled::SETS)
Rails.application.reloader.wrap do
::Gitlab::WithRequestStore.with_request_store do
if Feature.enabled?(:atomic_sidekiq_scheduler, default_enabled: :yaml)
atomic_find_jobs_and_enqueue(now, sorted_sets)
else
find_jobs_and_enqueue(now, sorted_sets)
end
ensure
::Gitlab::Database::LoadBalancing.release_hosts
end
end
end
private
......
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