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
cc9bb318
Commit
cc9bb318
authored
Oct 05, 2020
by
Jacob Vosmaer
Committed by
Kerri Miller
Oct 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add cleanup migration for JobWaiter Redis keys
parent
db3d0380
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
0 deletions
+67
-0
changelogs/unreleased/jv-cleanup-job-waiter.yml
changelogs/unreleased/jv-cleanup-job-waiter.yml
+5
-0
db/post_migrate/20200930144340_set_job_waiter_ttl.rb
db/post_migrate/20200930144340_set_job_waiter_ttl.rb
+31
-0
db/schema_migrations/20200930144340
db/schema_migrations/20200930144340
+1
-0
spec/migrations/set_job_waiter_ttl_spec.rb
spec/migrations/set_job_waiter_ttl_spec.rb
+30
-0
No files found.
changelogs/unreleased/jv-cleanup-job-waiter.yml
0 → 100644
View file @
cc9bb318
---
title
:
Add cleanup migration for JobWaiter Redis keys
merge_request
:
43882
author
:
type
:
fixed
db/post_migrate/20200930144340_set_job_waiter_ttl.rb
0 → 100644
View file @
cc9bb318
# frozen_string_literal: true
class
SetJobWaiterTtl
<
ActiveRecord
::
Migration
[
6.0
]
DOWNTIME
=
false
SCRIPT
=
<<~
LUA
.
freeze
if redis.call("ttl", KEYS[1]) < 0 then
redis.call("expire", KEYS[1], 21600)
end
LUA
def
up
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
cursor_init
=
'0'
cursor
=
cursor_init
loop
do
cursor
,
keys
=
redis
.
scan
(
cursor
,
match:
'gitlab:job_waiter:*'
)
redis
.
pipelined
do
|
redis
|
keys
.
each
{
|
k
|
redis
.
eval
(
SCRIPT
,
keys:
[
k
])
}
end
break
if
cursor
==
cursor_init
end
end
end
def
down
end
end
db/schema_migrations/20200930144340
0 → 100644
View file @
cc9bb318
febc66dbb48fbd281223ab9466cc5d94e945e8164fa9db0ee149c29e653b3eb2
\ No newline at end of file
spec/migrations/set_job_waiter_ttl_spec.rb
0 → 100644
View file @
cc9bb318
# frozen_string_literal: true
require
'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'post_migrate'
,
'20200930144340_set_job_waiter_ttl.rb'
)
RSpec
.
describe
SetJobWaiterTtl
,
:redis
do
it
'sets TTLs where necessary'
do
waiter_with_ttl
=
Gitlab
::
JobWaiter
.
new
.
key
waiter_without_ttl
=
Gitlab
::
JobWaiter
.
new
.
key
key_with_ttl
=
"foo:bar"
key_without_ttl
=
"foo:qux"
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
redis
.
set
(
waiter_with_ttl
,
"zzz"
,
ex:
2000
)
redis
.
set
(
waiter_without_ttl
,
"zzz"
)
redis
.
set
(
key_with_ttl
,
"zzz"
,
ex:
2000
)
redis
.
set
(
key_without_ttl
,
"zzz"
)
described_class
.
new
.
up
# This is the point of the migration. We know the migration uses a TTL of 21_600
expect
(
redis
.
ttl
(
waiter_without_ttl
)).
to
be
>
20_000
# Other TTL's should be untouched by the migration
expect
(
redis
.
ttl
(
waiter_with_ttl
)).
to
be_between
(
1000
,
2000
)
expect
(
redis
.
ttl
(
key_with_ttl
)).
to
be_between
(
1000
,
2000
)
expect
(
redis
.
ttl
(
key_without_ttl
)).
to
eq
(
-
1
)
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