Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
7f4df5cc
Commit
7f4df5cc
authored
Jan 12, 2022
by
Marius Bobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove alllow database cross join from runner_matchers
Changelog: other
parent
aa0eb491
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
14 deletions
+20
-14
app/models/ci/runner.rb
app/models/ci/runner.rb
+10
-12
ee/spec/lib/gitlab/ci/minutes/runners_availability_spec.rb
ee/spec/lib/gitlab/ci/minutes/runners_availability_spec.rb
+10
-2
No files found.
app/models/ci/runner.rb
View file @
7f4df5cc
...
...
@@ -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
...
...
ee/spec/lib/gitlab/ci/minutes/runners_availability_spec.rb
View file @
7f4df5cc
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment