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
fe073ca6
Commit
fe073ca6
authored
Sep 16, 2020
by
Qingyu Zhao
Committed by
Stan Hu
Sep 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix daemon memory killer jobs hash thread safety issue
parent
61350e7b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
4 deletions
+13
-4
changelogs/unreleased/249519-fix-daemon-jobs-hash-thread-safe-issue.yml
...eleased/249519-fix-daemon-jobs-hash-thread-safe-issue.yml
+5
-0
lib/gitlab/sidekiq_daemon/memory_killer.rb
lib/gitlab/sidekiq_daemon/memory_killer.rb
+4
-2
spec/lib/gitlab/sidekiq_daemon/memory_killer_spec.rb
spec/lib/gitlab/sidekiq_daemon/memory_killer_spec.rb
+4
-2
No files found.
changelogs/unreleased/249519-fix-daemon-jobs-hash-thread-safe-issue.yml
0 → 100644
View file @
fe073ca6
---
title
:
Fix daemon memory killer jobs hash thread safety issue
merge_request
:
42468
author
:
type
:
fixed
lib/gitlab/sidekiq_daemon/memory_killer.rb
View file @
fe073ca6
...
...
@@ -230,8 +230,10 @@ module Gitlab
end
def
rss_increase_by_jobs
Gitlab
::
SidekiqDaemon
::
Monitor
.
instance
.
jobs
.
sum
do
|
job
|
# rubocop:disable CodeReuse/ActiveRecord
rss_increase_by_job
(
job
)
Gitlab
::
SidekiqDaemon
::
Monitor
.
instance
.
jobs_mutex
.
synchronize
do
Gitlab
::
SidekiqDaemon
::
Monitor
.
instance
.
jobs
.
sum
do
|
job
|
# rubocop:disable CodeReuse/ActiveRecord
rss_increase_by_job
(
job
)
end
end
end
...
...
spec/lib/gitlab/sidekiq_daemon/memory_killer_spec.rb
View file @
fe073ca6
...
...
@@ -49,7 +49,7 @@ RSpec.describe Gitlab::SidekiqDaemon::MemoryKiller do
expect
{
subject
}.
not_to
raise_exception
end
it
'logs exception message once and raise ex
ec
ption and log stop message'
do
it
'logs exception message once and raise ex
ce
ption and log stop message'
do
expect
(
Sidekiq
.
logger
).
to
receive
(
:warn
).
once
.
with
(
class:
described_class
.
to_s
,
...
...
@@ -68,7 +68,7 @@ RSpec.describe Gitlab::SidekiqDaemon::MemoryKiller do
pid:
pid
,
message:
'Stopping Gitlab::SidekiqDaemon::MemoryKiller Daemon'
)
expect
{
subject
}.
to
raise_exception
expect
{
subject
}.
to
raise_exception
(
Exception
,
'My Exception'
)
end
it
'logs stop message once'
do
...
...
@@ -402,12 +402,14 @@ RSpec.describe Gitlab::SidekiqDaemon::MemoryKiller do
subject
{
memory_killer
.
send
(
:rss_increase_by_jobs
)
}
it
'adds up individual rss_increase_by_job'
do
allow
(
Gitlab
::
SidekiqDaemon
::
Monitor
).
to
receive_message_chain
(
:instance
,
:jobs_mutex
,
:synchronize
).
and_yield
expect
(
Gitlab
::
SidekiqDaemon
::
Monitor
).
to
receive_message_chain
(
:instance
,
:jobs
).
and_return
(
running_jobs
)
expect
(
memory_killer
).
to
receive
(
:rss_increase_by_job
).
and_return
(
11
,
22
)
expect
(
subject
).
to
eq
(
33
)
end
it
'return 0 if no job'
do
allow
(
Gitlab
::
SidekiqDaemon
::
Monitor
).
to
receive_message_chain
(
:instance
,
:jobs_mutex
,
:synchronize
).
and_yield
expect
(
Gitlab
::
SidekiqDaemon
::
Monitor
).
to
receive_message_chain
(
:instance
,
:jobs
).
and_return
({})
expect
(
subject
).
to
eq
(
0
)
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