Merge branch 'dm-batch-loader-sidekiq' into 'master'

Clear BatchLoader context between Sidekiq jobs

Closes #53079

See merge request gitlab-org/gitlab-ce!23308
This commit is contained in:
Stan Hu 2018-11-22 18:04:34 +00:00
commit a033faa2a6
3 changed files with 19 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
title: Clear BatchLoader context between Sidekiq jobs
merge_request: 23308
author:
type: fixed

View file

@ -20,6 +20,7 @@ Sidekiq.configure_server do |config|
chain.add Gitlab::SidekiqMiddleware::ArgumentsLogger if ENV['SIDEKIQ_LOG_ARGUMENTS'] && !enable_json_logs
chain.add Gitlab::SidekiqMiddleware::Shutdown
chain.add Gitlab::SidekiqMiddleware::RequestStoreMiddleware unless ENV['SIDEKIQ_REQUEST_STORE'] == '0'
chain.add Gitlab::SidekiqMiddleware::BatchLoader
chain.add Gitlab::SidekiqStatus::ServerMiddleware
end

View file

@ -0,0 +1,13 @@
# frozen_string_literal: true
module Gitlab
module SidekiqMiddleware
class BatchLoader
def call(worker, job, queue)
yield
ensure
::BatchLoader::Executor.clear_current
end
end
end
end