Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions sentry-rails/lib/sentry/rails/background_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@

module Sentry
class BackgroundWorker
def _perform(&block)
block.call
ensure
# 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.release_connection
module ActiveRecordConnectionPatch
def _perform(&block)
super(&block)
ensure
# 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.release_connection
end
end
end
end
end

Sentry::BackgroundWorker.prepend(Sentry::BackgroundWorker::ActiveRecordConnectionPatch)
Loading