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
59feaea0
Commit
59feaea0
authored
Mar 21, 2021
by
Thong Kuah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use DISTINCT in group runner query for RegisterJobService
parent
f205ce09
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
1 deletion
+29
-1
app/services/ci/register_job_service.rb
app/services/ci/register_job_service.rb
+1
-1
config/feature_flags/development/use_distinct_in_register_job_object_hierarchy.yml
...lopment/use_distinct_in_register_job_object_hierarchy.yml
+8
-0
spec/services/ci/register_job_service_spec.rb
spec/services/ci/register_job_service_spec.rb
+20
-0
No files found.
app/services/ci/register_job_service.rb
View file @
59feaea0
...
...
@@ -278,7 +278,7 @@ module Ci
# Workaround for weird Rails bug, that makes `runner.groups.to_sql` to return `runner_id = NULL`
groups
=
::
Group
.
joins
(
:runner_namespaces
).
merge
(
runner
.
runner_namespaces
)
hierarchy_groups
=
Gitlab
::
ObjectHierarchy
.
new
(
groups
).
base_and_descendants
hierarchy_groups
=
Gitlab
::
ObjectHierarchy
.
new
(
groups
,
options:
{
use_distinct:
Feature
.
enabled?
(
:use_distinct_in_register_job_object_hierarchy
)
}
).
base_and_descendants
projects
=
Project
.
where
(
namespace_id:
hierarchy_groups
)
.
with_group_runners_enabled
.
with_builds_enabled
...
...
config/feature_flags/development/use_distinct_in_register_job_object_hierarchy.yml
0 → 100644
View file @
59feaea0
---
name
:
use_distinct_in_register_job_object_hierarchy
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/57045
rollout_issue_url
:
milestone
:
'
13.11'
type
:
development
group
:
group::continuous integration
default_enabled
:
false
spec/services/ci/register_job_service_spec.rb
View file @
59feaea0
...
...
@@ -225,6 +225,26 @@ module Ci
end
end
context
'when the use_distinct_in_register_job_object_hierarchy feature flag is enabled'
do
before
do
stub_feature_flags
(
use_distinct_in_register_job_object_hierarchy:
true
)
end
it
'calls DISTINCT'
do
expect
(
described_class
.
new
(
group_runner
).
send
(
:builds_for_group_runner
).
to_sql
).
to
include
(
"DISTINCT"
)
end
end
context
'when the use_distinct_in_register_job_object_hierarchy feature flag is disabled'
do
before
do
stub_feature_flags
(
use_distinct_in_register_job_object_hierarchy:
false
)
end
it
'does not call DISTINCT'
do
expect
(
described_class
.
new
(
group_runner
).
send
(
:builds_for_group_runner
).
to_sql
).
not_to
include
(
"DISTINCT"
)
end
end
context
'group runner'
do
let
(
:build
)
{
execute
(
group_runner
)
}
...
...
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