Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gpt
large_projects
gitlabhq1
Commits
a2ccfa79
Commit
a2ccfa79
authored
7 years ago
by
Shinya Maeda
Browse files
Options
Download
Email Patches
Plain Diff
Add TTL refresh worker
parent
8a7654a5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
4 deletions
+36
-4
app/models/ci/job_trace_chunk.rb
app/models/ci/job_trace_chunk.rb
+9
-4
app/workers/build_trace_ttl_extend_worker.rb
app/workers/build_trace_ttl_extend_worker.rb
+12
-0
app/workers/build_trace_ttl_refresh_worker.rb
app/workers/build_trace_ttl_refresh_worker.rb
+15
-0
No files found.
app/models/ci/job_trace_chunk.rb
View file @
a2ccfa79
...
...
@@ -4,14 +4,13 @@ module Ci
belongs_to
:job
,
class_name:
"Ci::Build"
,
foreign_key: :job_id
after_destroy
:redis_delete_data
,
if: :redis?
default_value_for
:data_store
,
:redis
WriteError
=
Class
.
new
(
StandardError
)
CHUNK_SIZE
=
128
.
kilobytes
CHUNK_REDIS_TTL
=
1
.
week
CHUNK_REDIS_TTL
=
1
.
day
CHUNK_REDIS_TTL_REFRESH
=
6
.
hours
LOCK_RETRY
=
100
LOCK_SLEEP
=
1
LOCK_TTL
=
5
.
minutes
...
...
@@ -87,6 +86,12 @@ module Ci
end
end
def
redis_extend_ttl
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
redis
.
setex
(
redis_data_key
,
CHUNK_REDIS_TTL
,
data
)
end
end
private
def
schedule_to_db
...
...
@@ -115,7 +120,7 @@ module Ci
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
redis
.
del
(
redis_data_key
)
end
end
end
def
redis_data_key
"gitlab:ci:trace:
#{
job_id
}
:chunks:
#{
chunk_index
}
:data"
...
...
This diff is collapsed.
Click to expand it.
app/workers/build_trace_ttl_extend_worker.rb
0 → 100644
View file @
a2ccfa79
class
BuildTraceTTLRefreshWorker
include
ApplicationWorker
include
PipelineQueue
queue_namespace
:pipeline_processing
def
perform
(
job_trace_chunk_id_min
,
job_trace_chunk_id_max
)
Ci
::
JobTraceChunk
.
redis
.
where
(
:id
=>
(
job_trace_chunk_id_min
..
job_trace_chunk_id_max
))
.
map
(
&
:redis_extend_ttl
)
end
end
This diff is collapsed.
Click to expand it.
app/workers/build_trace_ttl_refresh_worker.rb
0 → 100644
View file @
a2ccfa79
class
BuildTraceTTLRefreshWorker
include
ApplicationWorker
include
CronjobQueue
def
perform
Ci
::
JobTraceChunk
.
redis
# Stored in redis
.
joins
(
:ci_builds
)
.
where
(
'NOT EXISTS (?)'
,
# If the trace has not been archived yet
Ci
::
JobArtifact
.
select
(
1
).
trace
.
where
(
'ci_builds.id = ci_job_artifacts.job_id'
))
.
where
(
'ci_builds.update_at < ?'
,
CHUNK_REDIS_TTL_REFRESH
.
ago
)
# If the live-trace has not been updated over 6h
.
find_in_batches
(
batch_size:
1000
)
do
|
job_trace_chunks
|
BuildTraceTTLExtendWorker
.
perform_async
(
job_trace_chunks
.
minimum
(
:id
),
job_trace_chunks
.
maximum
(
:id
))
end
end
end
This diff is collapsed.
Click to expand it.
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