Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update clear_active_connections! to resolve deprecation warning in activerecord 7.1 #407

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AndreasBaumgart
Copy link

With activerecord (= 7.1.1), the following deprecation warning is received on master:

DEPRECATION WARNING: Calling `ActiveRecord::Base.clear_active_connections! is deprecated. Please call the method directly on the connection handler; for example: `ActiveRecord::Base.connection_handler.clear_active_connections!`

This PR replaces the call to ActiveRecord::Base.clear_active_connections! with the now recommended method ActiveRecord::Base.connection_handler.clear_active_connections!. This change ensures compatibility with future versions of ActiveRecord and follows current recommendations.

@AndreasBaumgart AndreasBaumgart marked this pull request as ready for review November 14, 2023 16:16
@AndreasBaumgart AndreasBaumgart changed the title Update clear_active_connections! Method to Resolve Deprecation Warning in ActiveRecord 7.1.1 Update clear_active_connections! Method to Resolve Deprecation Warning in ActiveRecord 7.1 Nov 14, 2023
@AndreasBaumgart AndreasBaumgart changed the title Update clear_active_connections! Method to Resolve Deprecation Warning in ActiveRecord 7.1 Update clear_active_connections! to resolve deprecation warning in activerecord 7.1 Nov 14, 2023
@tomgi
Copy link
Contributor

tomgi commented Dec 5, 2023

Cool!

I noticed there's another deprecation warning related to the same method:
DEPRECATION WARNING: clear_active_connections! currently only applies to connection pools in the current role (writing). In Rails 7.2, this method will apply to all known pools, regardless of role. To affect only those connections belonging to a specific role, pass the role name as an argument. To switch to the new behavior, pass :all as the role name. (called from call at /app/.bundle/ruby/3.2.0/bundler/gems/shoryuken-869fb0c77f8e/lib/shoryuken/middleware/server/active_record.rb:8)

@AndreasBaumgart Do you think we could fix them both at once?

@tomgi
Copy link
Contributor

tomgi commented Jan 5, 2024

@AndreasBaumgart I combined your fix with the second deprecation warning fix, and a backward-compatibility with older version of rails

Have a look if you want to pull these changed into your PR master...tomgi:que:activerecord_deprecation_warning

@filipegiusti
Copy link

@tomgi, given @AndreasBaumgart has been unresponsive, it would be nice if you could open a new PR with you changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants