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
33019bea
Commit
33019bea
authored
May 21, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify RescueStaleLiveTraceWorker
parent
25810d03
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
23 deletions
+6
-23
app/workers/rescue_stale_live_trace_worker.rb
app/workers/rescue_stale_live_trace_worker.rb
+4
-21
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+2
-2
No files found.
app/workers/rescue_stale_live_trace_worker.rb
View file @
33019bea
...
...
@@ -6,34 +6,17 @@ class RescueStaleLiveTraceWorker
# Reschedule to archive live traces
#
# The target jobs are with the following conditions
# - Finished
4 hours ago, but it's not archived
yet
# Jobs finished
4 hours
ago should have an archived trace. Probably ArchiveTraceWorker failed by Sidekiq's inconsistancy
# - 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
Ci
::
Build
.
finished
.
where
(
'finished_at BETWEEN ? AND ?'
,
1
.
week
.
ago
,
4
.
hours
.
ago
)
.
where
(
'finished_at BETWEEN ? AND ?'
,
1
.
week
.
ago
,
1
.
day
.
ago
)
.
where
(
'NOT EXISTS (?)'
,
Ci
::
JobArtifact
.
select
(
1
).
trace
.
where
(
'ci_builds.id = ci_job_artifacts.job_id'
))
.
find_in_batch
(
batch_size:
100
0
)
do
|
jobs
|
.
find_in_batch
(
batch_size:
100
)
do
|
jobs
|
job_ids
=
jobs
.
map
{
|
job
|
[
job
.
id
]
}
ArchiveTraceWorker
.
bulk_perform_async
(
job_ids
)
Rails
.
logger
.
warning
"Scheduled to archive stale live traces from
#{
job_ids
.
min
}
to
#{
job_ids
.
max
}
"
end
# Schedule to flush redis-chunk to database
#
# The target build_trace_chunks are with the following conditions
# - The last patching of the trace was 1 hour ago
# - The job is still running
Ci
::
BuildTraceChunk
.
redis
.
joins
(
:build
)
.
where
(
'ci_builds.update_at < ?'
,
1
.
hour
.
ago
)
.
where
(
'ci_builds.status = ?'
,
'running'
)
.
find_in_batch
(
batch_size:
1000
)
do
|
build_trace_chunks
|
build_trace_chunk_ids
=
build_trace_chunks
.
map
{
|
build_trace_chunk
|
[
build_trace_chunk
.
id
]
}
BuildTraceChunkFlushToDBWorker
.
bulk_perform_async
(
build_trace_chunk_ids
)
Rails
.
logger
.
warning
"Scheduled to flush stale live traces to database from
#{
build_trace_chunk_ids
.
min
}
to
#{
build_trace_chunk_ids
.
max
}
"
end
end
end
config/initializers/1_settings.rb
View file @
33019bea
...
...
@@ -290,8 +290,8 @@ Settings.cron_jobs['import_export_project_cleanup_worker'] ||= Settingslogic.new
Settings
.
cron_jobs
[
'import_export_project_cleanup_worker'
][
'cron'
]
||=
'0 * * * *'
Settings
.
cron_jobs
[
'import_export_project_cleanup_worker'
][
'job_class'
]
=
'ImportExportProjectCleanupWorker'
Settings
.
cron_jobs
[
'rescue_stale_live_trace_worker'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'rescue_stale_live_trace_worker'
][
'cron'
]
||=
'*/1 * * * *'
Settings
.
cron_jobs
[
'rescue_stale_live_trace_worker'
][
'job_class'
]
=
'
BuildTraceChunkArchiveStaleObjects
Worker'
Settings
.
cron_jobs
[
'rescue_stale_live_trace_worker'
][
'cron'
]
||=
'*/1
2
* * * *'
Settings
.
cron_jobs
[
'rescue_stale_live_trace_worker'
][
'job_class'
]
=
'
RescueStaleLiveTrace
Worker'
Settings
.
cron_jobs
[
'requests_profiles_worker'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'requests_profiles_worker'
][
'cron'
]
||=
'0 0 * * *'
Settings
.
cron_jobs
[
'requests_profiles_worker'
][
'job_class'
]
=
'RequestsProfilesWorker'
...
...
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