Clear AR connections before starting Sidekiq

This should ensure that connections obtained before starting Sidekiq are
not leaked, leading to connection timeouts.

Fixes gitlab-com/infrastructure#1139
This commit is contained in:
Yorick Peterse 2017-03-07 18:01:20 +01:00
parent 7f2819b778
commit fb697e69f2
No known key found for this signature in database
GPG Key ID: EDD30D2BEB691AC9
2 changed files with 10 additions and 0 deletions

View File

@ -0,0 +1,4 @@
---
title: Clear ActiveRecord connections before starting Sidekiq
merge_request:
author:

View File

@ -19,6 +19,12 @@ Sidekiq.configure_server do |config|
chain.add Gitlab::SidekiqStatus::ClientMiddleware
end
config.on :startup do
# Clear any connections that might have been obtained before starting
# Sidekiq (e.g. in an initializer).
ActiveRecord::Base.clear_all_connections!
end
# Sidekiq-cron: load recurring jobs from gitlab.yml
# UGLY Hack to get nested hash from settingslogic
cron_jobs = JSON.parse(Gitlab.config.cron_jobs.to_json)