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
cd9a92a9
Commit
cd9a92a9
authored
Dec 19, 2019
by
Alishan Ladhani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Limit the amount of time ChatNotificationWorker waits for build trace
See
https://gitlab.com/gitlab-org/gitlab/issues/119198
parent
e77a7025
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
10 deletions
+39
-10
app/workers/chat_notification_worker.rb
app/workers/chat_notification_worker.rb
+11
-2
changelogs/unreleased/119198-chat_notification-sidekiq-job-latency-has-increased.yml
...8-chat_notification-sidekiq-job-latency-has-increased.yml
+5
-0
spec/workers/chat_notification_worker_spec.rb
spec/workers/chat_notification_worker_spec.rb
+23
-8
No files found.
app/workers/chat_notification_worker.rb
View file @
cd9a92a9
...
...
@@ -11,18 +11,21 @@ class ChatNotificationWorker
# worker_has_external_dependencies!
RESCHEDULE_INTERVAL
=
2
.
seconds
RESCHEDULE_TIMEOUT
=
5
.
minutes
# rubocop: disable CodeReuse/ActiveRecord
def
perform
(
build_id
)
def
perform
(
build_id
,
reschedule_count
=
0
)
Ci
::
Build
.
find_by
(
id:
build_id
).
try
do
|
build
|
send_response
(
build
)
end
rescue
Gitlab
::
Chat
::
Output
::
MissingBuildSectionError
return
if
timeout_exceeded?
(
reschedule_count
)
# The creation of traces and sections appears to be eventually consistent.
# As a result it's possible for us to run the above code before the trace
# sections are present. To better handle such cases we'll just reschedule
# the job instead of producing an error.
self
.
class
.
perform_in
(
RESCHEDULE_INTERVAL
,
build_id
)
self
.
class
.
perform_in
(
RESCHEDULE_INTERVAL
,
build_id
,
reschedule_count
+
1
)
end
# rubocop: enable CodeReuse/ActiveRecord
...
...
@@ -37,4 +40,10 @@ class ChatNotificationWorker
end
end
end
private
def
timeout_exceeded?
(
reschedule_count
)
(
reschedule_count
*
RESCHEDULE_INTERVAL
)
>=
RESCHEDULE_TIMEOUT
end
end
changelogs/unreleased/119198-chat_notification-sidekiq-job-latency-has-increased.yml
0 → 100644
View file @
cd9a92a9
---
title
:
Limit the amount of time ChatNotificationWorker waits for the build trace
merge_request
:
22132
author
:
type
:
fixed
spec/workers/chat_notification_worker_spec.rb
View file @
cd9a92a9
...
...
@@ -23,16 +23,31 @@ describe ChatNotificationWorker do
worker
.
perform
(
chat_build
.
id
)
end
it
'reschedules the job if the trace sections could not be found'
do
expect
(
worker
)
.
to
receive
(
:send_response
)
.
and_raise
(
Gitlab
::
Chat
::
Output
::
MissingBuildSectionError
)
context
'when the trace sections could not be found'
do
it
'reschedules the job'
do
expect
(
worker
)
.
to
receive
(
:send_response
)
.
and_raise
(
Gitlab
::
Chat
::
Output
::
MissingBuildSectionError
)
expect
(
described_class
)
.
to
receive
(
:perform_in
)
.
with
(
described_class
::
RESCHEDULE_INTERVAL
,
chat_build
.
id
)
expect
(
described_class
)
.
to
receive
(
:perform_in
)
.
with
(
described_class
::
RESCHEDULE_INTERVAL
,
chat_build
.
id
,
1
)
worker
.
perform
(
chat_build
.
id
)
worker
.
perform
(
chat_build
.
id
)
end
it
"stops rescheduling the job after
#{
described_class
::
RESCHEDULE_TIMEOUT
}
seconds"
do
allow
(
described_class
).
to
receive
(
:new
).
and_return
(
worker
)
allow
(
worker
).
to
receive
(
:send_response
).
and_raise
(
Gitlab
::
Chat
::
Output
::
MissingBuildSectionError
)
worker
.
perform
(
chat_build
.
id
)
described_class
.
drain
max_reschedules
=
described_class
::
RESCHEDULE_TIMEOUT
/
described_class
::
RESCHEDULE_INTERVAL
expect
(
worker
).
to
have_received
(
:send_response
).
exactly
(
max_reschedules
+
1
).
times
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