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
Jérome Perrin
gitlab-ce
Commits
477c83f6
Commit
477c83f6
authored
Mar 05, 2018
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ports
https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/4747
to CE
parent
b7cacaaf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
2 deletions
+15
-2
config/initializers/forbid_sidekiq_in_transactions.rb
config/initializers/forbid_sidekiq_in_transactions.rb
+15
-2
No files found.
config/initializers/forbid_sidekiq_in_transactions.rb
View file @
477c83f6
...
...
@@ -18,13 +18,26 @@ module Sidekiq
%i(perform_async perform_at perform_in)
.
each
do
|
name
|
define_method
(
name
)
do
|*
args
|
if
!
Sidekiq
::
Worker
.
skip_transaction_check
&&
AfterCommitQueue
.
inside_transaction?
raise
Sidekiq
::
Worker
::
EnqueueFromTransactionError
,
<<~
MSG
begin
raise
Sidekiq
::
Worker
::
EnqueueFromTransactionError
,
<<~
MSG
`
#{
self
}
.
#{
name
}
` cannot be called inside a transaction as this can lead to
race conditions when the worker runs before the transaction is committed and
tries to access a model that has not been saved yet.
Use an `after_commit` hook, or include `AfterCommitQueue` and use a `run_after_commit` block instead.
MSG
MSG
rescue
Sidekiq
::
Worker
::
EnqueueFromTransactionError
=>
e
if
Rails
.
env
.
production?
Rails
.
logger
.
error
(
e
.
message
)
if
Gitlab
::
Sentry
.
enabled?
Gitlab
::
Sentry
.
context
Raven
.
capture_exception
(
e
)
end
else
raise
end
end
end
super
(
*
args
)
...
...
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