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
aa8b9434
Commit
aa8b9434
authored
Oct 01, 2021
by
Allison Browne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize stuck running job
- Optimize query plan
parent
afdec687
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
13 deletions
+7
-13
app/services/ci/stuck_builds/drop_running_service.rb
app/services/ci/stuck_builds/drop_running_service.rb
+5
-2
spec/services/ci/stuck_builds/drop_running_service_spec.rb
spec/services/ci/stuck_builds/drop_running_service_spec.rb
+2
-11
No files found.
app/services/ci/stuck_builds/drop_running_service.rb
View file @
aa8b9434
...
...
@@ -17,8 +17,11 @@ module Ci
def
running_timed_out_builds
if
Feature
.
enabled?
(
:ci_new_query_for_running_stuck_jobs
,
default_enabled: :yaml
)
running_builds
=
Ci
::
Build
.
running
.
created_at_before
(
BUILD_RUNNING_OUTDATED_TIMEOUT
.
ago
).
order
(
created_at: :asc
,
project_id: :asc
)
# rubocop: disable CodeReuse/ActiveRecord
Ci
::
Build
.
id_in
(
running_builds
).
updated_at_before
(
BUILD_RUNNING_OUTDATED_TIMEOUT
.
ago
)
Ci
::
Build
.
running
.
created_at_before
(
BUILD_RUNNING_OUTDATED_TIMEOUT
.
ago
)
.
updated_at_before
(
BUILD_RUNNING_OUTDATED_TIMEOUT
.
ago
)
.
order
(
created_at: :asc
,
project_id: :asc
)
# rubocop:disable CodeReuse/ActiveRecord
else
Ci
::
Build
.
running
.
updated_at_before
(
BUILD_RUNNING_OUTDATED_TIMEOUT
.
ago
)
end
...
...
spec/services/ci/stuck_builds/drop_running_service_spec.rb
View file @
aa8b9434
...
...
@@ -4,19 +4,10 @@ require 'spec_helper'
RSpec
.
describe
Ci
::
StuckBuilds
::
DropRunningService
do
let!
(
:runner
)
{
create
:ci_runner
}
let!
(
:job
)
{
create
:ci_build
,
runner:
runner
}
let
(
:created_at
)
{
}
let
(
:updated_at
)
{
}
let!
(
:job
)
{
create
(
:ci_build
,
runner:
runner
,
created_at:
created_at
,
updated_at:
updated_at
,
status:
status
)
}
subject
(
:service
)
{
described_class
.
new
}
before
do
job_attributes
=
{
status:
status
}
job_attributes
[
:created_at
]
=
created_at
if
created_at
job_attributes
[
:updated_at
]
=
updated_at
if
updated_at
job
.
update!
(
job_attributes
)
end
around
do
|
example
|
freeze_time
{
example
.
run
}
end
...
...
@@ -52,7 +43,7 @@ RSpec.describe Ci::StuckBuilds::DropRunningService do
include_examples
'running builds'
context
'when
ci_new_query_for_running_stuck_jobs
flag is disabled'
do
context
'when
new query
flag is disabled'
do
before
do
stub_feature_flags
(
ci_new_query_for_running_stuck_jobs:
false
)
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