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
c33cedd0
Commit
c33cedd0
authored
May 22, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use each_batch to find rows efficiently with group_by
parent
d10fbde4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
app/workers/rescue_stale_live_trace_worker.rb
app/workers/rescue_stale_live_trace_worker.rb
+5
-4
No files found.
app/workers/rescue_stale_live_trace_worker.rb
View file @
c33cedd0
...
...
@@ -6,20 +6,21 @@ class RescueStaleLiveTraceWorker
# Reschedule to archive live traces
#
# The target jobs are with the following conditions
# - Finished 1
day
ago, but it has not had an acthived trace yet
# Jobs finished 1
day
ago should have an archived trace. Probably ArchiveTraceWorker failed by Sidekiq's inconsistancy
# - Finished 1
hour
ago, but it has not had an acthived trace yet
# Jobs finished 1
hour
ago should have an archived trace. Probably ArchiveTraceWorker failed by Sidekiq's inconsistancy
Ci
::
BuildTraceChunk
.
include
(
EachBatch
)
.
select
(
:build_id
)
.
group
(
:build_id
)
.
joins
(
:build
)
.
merge
(
Ci
::
Build
.
finished
)
.
where
(
'ci_builds.finished_at < ?'
,
1
.
hour
.
ago
)
.
each
do
|
chunks
|
# TODO: find_each gives an error because of group_by
.
each
_batch
(
column: :build_id
)
do
|
chunks
|
build_ids
=
chunks
.
map
{
|
chunk
|
[
chunk
.
build_id
]
}
ArchiveTraceWorker
.
bulk_perform_async
(
build_ids
)
Rails
.
logger
.
warning
"Scheduled to archive stale live traces from
#{
build_ids
.
min
}
to
#{
build_ids
.
max
}
"
Rails
.
logger
.
info
"Scheduled to archive stale live traces from
#{
build_ids
.
min
}
to
#{
build_ids
.
max
}
"
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