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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
a26e25ea
Commit
a26e25ea
authored
Nov 21, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimise StuckCiJobsWorker
parent
03b891c5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
+13
-3
app/workers/stuck_ci_jobs_worker.rb
app/workers/stuck_ci_jobs_worker.rb
+8
-3
changelogs/unreleased/optimise-stuck-ci-jobs-worker.yml
changelogs/unreleased/optimise-stuck-ci-jobs-worker.yml
+5
-0
No files found.
app/workers/stuck_ci_jobs_worker.rb
View file @
a26e25ea
...
@@ -45,9 +45,13 @@ class StuckCiJobsWorker
...
@@ -45,9 +45,13 @@ class StuckCiJobsWorker
end
end
def
search
(
status
,
timeout
)
def
search
(
status
,
timeout
)
builds
=
Ci
::
Build
.
where
(
status:
status
).
where
(
'ci_builds.updated_at < ?'
,
timeout
.
ago
)
Ci
::
Build
.
where
(
status:
status
).
in_batches
(
of:
1000
)
do
|
batch
|
builds
.
joins
(
:project
).
merge
(
Project
.
without_deleted
).
includes
(
:tags
,
:runner
,
project: :namespace
).
find_each
(
batch_size:
50
).
each
do
|
build
|
batch
=
batch
.
where
(
'ci_builds.updated_at < ?'
,
timeout
.
ago
)
yield
(
build
)
.
joins
(
:project
).
merge
(
Project
.
without_deleted
)
.
includes
(
:tags
,
:runner
,
project: :namespace
)
batch
.
each
do
|
build
|
yield
(
build
)
end
end
end
end
end
...
@@ -58,3 +62,4 @@ class StuckCiJobsWorker
...
@@ -58,3 +62,4 @@ class StuckCiJobsWorker
end
end
end
end
end
end
changelogs/unreleased/optimise-stuck-ci-jobs-worker.yml
0 → 100644
View file @
a26e25ea
---
title
:
Optimise StuckCiJobsWorker using cheap SQL query outside, and expensive inside
merge_request
:
author
:
type
:
performance
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