Commit 7f4df5cc authored by Marius Bobin's avatar Marius Bobin

Remove alllow database cross join from runner_matchers

Changelog: other
parent aa0eb491
......@@ -255,18 +255,16 @@ module Ci
Arel.sql("(#{arel_tag_names_array.to_sql})")
]
::Gitlab::Database.allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/339621') do
group(*unique_params).pluck('array_agg(ci_runners.id)', *unique_params).map do |values|
Gitlab::Ci::Matching::RunnerMatcher.new({
runner_ids: values[0],
runner_type: values[1],
public_projects_minutes_cost_factor: values[2],
private_projects_minutes_cost_factor: values[3],
run_untagged: values[4],
access_level: values[5],
tag_list: values[6]
})
end
group(*unique_params).pluck('array_agg(ci_runners.id)', *unique_params).map do |values|
Gitlab::Ci::Matching::RunnerMatcher.new({
runner_ids: values[0],
runner_type: values[1],
public_projects_minutes_cost_factor: values[2],
private_projects_minutes_cost_factor: values[3],
run_untagged: values[4],
access_level: values[5],
tag_list: values[6]
})
end
end
......
......@@ -33,9 +33,11 @@ RSpec.describe Gitlab::Ci::Minutes::RunnersAvailability do
end
end
context 'N+1 queries' do
context 'database queries' do
let_it_be(:project) { create(:project) }
let_it_be(:private_runner) { create(:ci_runner, :project, :online, projects: [project]) }
let_it_be(:private_runner) do
create(:ci_runner, :project, :online, projects: [project])
end
it 'caches records loaded from database' do
ActiveRecord::QueryRecorder.new(skip_cached: false) do
......@@ -44,5 +46,11 @@ RSpec.describe Gitlab::Ci::Minutes::RunnersAvailability do
expect { minutes.available?(build.build_matcher) }.not_to exceed_all_query_limit(0)
end
it 'does not join across databases' do
with_cross_joins_prevented do
minutes.available?(build.build_matcher)
end
end
end
end
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