From 1039242476beb113396eb177922927df5a57cc2b Mon Sep 17 00:00:00 2001 From: Matt Findley Date: Wed, 5 Oct 2022 08:18:21 -0700 Subject: [PATCH 1/2] Release connection pool only when active record is connected --- sentry-rails/lib/sentry/rails/background_worker.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sentry-rails/lib/sentry/rails/background_worker.rb b/sentry-rails/lib/sentry/rails/background_worker.rb index c3167c841..56dcd6609 100644 --- a/sentry-rails/lib/sentry/rails/background_worker.rb +++ b/sentry-rails/lib/sentry/rails/background_worker.rb @@ -3,8 +3,11 @@ class BackgroundWorker def _perform(&block) block.call ensure - # make sure the background worker returns AR connection if it accidentally acquire one during serialization - ActiveRecord::Base.connection_pool.release_connection + # 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 From 0b2f4fc864acba041a8e2a5f97c910325f1fb326 Mon Sep 17 00:00:00 2001 From: Matt Findley Date: Thu, 6 Oct 2022 07:22:16 -0700 Subject: [PATCH 2/2] CHANGELOG is updated --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50735b1f2..b623b621b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## Unreleased + +### Bug Fixes + +- `Sentry::BackgroundWorker` will release `ActiveRecord` connection pool only when the `ActiveRecord` connection is established + ## 5.5.0 ### Features