-
-
Notifications
You must be signed in to change notification settings - Fork 485
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't require a DB connection, but release one if it is acquired (#1812)
- Loading branch information
1 parent
fb80e1f
commit bcfdec5
Showing
1 changed file
with
4 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,10 @@ | ||
module Sentry | ||
class BackgroundWorker | ||
def _perform(&block) | ||
# some applications have partial or even no AR connection | ||
if ActiveRecord::Base.connected? | ||
# make sure the background worker returns AR connection if it accidentally acquire one during serialization | ||
ActiveRecord::Base.connection_pool.with_connection do | ||
block.call | ||
end | ||
else | ||
block.call | ||
end | ||
block.call | ||
ensure | ||
# make sure the background worker returns AR connection if it accidentally acquire one during serialization | ||
ActiveRecord::Base.connection_pool.release_connection | ||
end | ||
end | ||
end |