diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a65b6310..0c63c4bd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### Bug Fixes +- `Sentry::BackgroundWorker` will release `ActiveRecord` connection pool only when the `ActiveRecord` connection is established - Remove bad encoding arguments in redis span descriptions [#1914](https://github.com/getsentry/sentry-ruby/pull/1914) - Fixes [#1911](https://github.com/getsentry/sentry-ruby/issues/1911) 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