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
Boxiang Sun
gitlab-ce
Commits
3b569fce
Commit
3b569fce
authored
May 31, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up worker
parent
ded38d5f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
26 deletions
+38
-26
app/models/ci/build_trace_chunk.rb
app/models/ci/build_trace_chunk.rb
+15
-0
app/workers/ci/rescue_stale_live_trace_worker.rb
app/workers/ci/rescue_stale_live_trace_worker.rb
+23
-0
app/workers/rescue_stale_live_trace_worker.rb
app/workers/rescue_stale_live_trace_worker.rb
+0
-26
No files found.
app/models/ci/build_trace_chunk.rb
View file @
3b569fce
...
@@ -50,6 +50,21 @@ module Ci
...
@@ -50,6 +50,21 @@ module Ci
def
finalize_fast_destroy
(
keys
)
def
finalize_fast_destroy
(
keys
)
redis_delete_data
(
keys
)
redis_delete_data
(
keys
)
end
end
# Find stale live traces and return their build ids
def
find_stale
(
finished_before:
1
.
hour
.
ago
)
include
(
EachBatch
)
.
select
(
:build_id
)
.
group
(
:build_id
)
.
joins
(
:build
)
.
merge
(
Ci
::
Build
.
finished
)
.
where
(
'ci_builds.finished_at < ?'
,
finished_before
)
.
each_batch
(
column: :build_id
)
do
|
chunks
|
build_ids
=
chunks
.
map
{
|
chunk
|
[
chunk
.
build_id
]
}
yield
build_ids
end
end
end
end
##
##
...
...
app/workers/ci/rescue_stale_live_trace_worker.rb
0 → 100644
View file @
3b569fce
module
Ci
class
RescueStaleLiveTraceWorker
include
ApplicationWorker
include
CronjobQueue
def
perform
# Reschedule to archive live traces
#
# The targets are jobs with the following conditions
# - It had been finished 1 hour ago, but it has not had an acthived trace yet
# This case happens when sidekiq-jobs of archiving traces are lost in order to restart sidekiq instace which hit RSS limit
Ci
::
BuildTraceChunk
.
find_stale
(
finished_before:
1
.
hour
.
ago
)
do
|
build_ids
|
Ci
::
Build
.
where
(
id:
build_ids
).
find_each
do
|
build
|
begin
build
.
trace
.
archive!
rescue
=>
e
Rails
.
logger
.
info
"Failed to archive stale live trace. id:
#{
build
.
id
}
message:
#{
e
.
message
}
"
end
end
end
end
end
end
app/workers/rescue_stale_live_trace_worker.rb
deleted
100644 → 0
View file @
ded38d5f
class
RescueStaleLiveTraceWorker
include
ApplicationWorker
include
CronjobQueue
def
perform
# Reschedule to archive live traces
#
# The targets are jobs with the following conditions
# - It had been finished 1 hour ago, but it has not had an acthived trace yet
# This case happens when sidekiq-jobs of archiving traces are lost in order to restart sidekiq instace which hit RSS limit
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_batch
(
column: :build_id
)
do
|
chunks
|
build_ids
=
chunks
.
map
{
|
chunk
|
[
chunk
.
build_id
]
}
ArchiveTraceWorker
.
bulk_perform_async
(
build_ids
)
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