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

Fix clear_active_connections! with no argument deprecation warning #217

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

Conversation

zzak
Copy link

@zzak zzak commented Nov 21, 2024

We're using gruf v2.20.1, and still experience the deprecation warning for clear_active_connections!.

DEPRECATION WARNING: `clear_active_connections!` currently only applies to connection pools in the current role (`reading`).
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 block in call at gruf/lib/gruf/interceptors/active_record/connection_reset.rb:32)>

This is caused by rails/rails#45924.

If you're still supporting Rails < 7.1, then we should change this to use ActiveRecord::Base.current_role, but I thought your goal was to clear any and all active connections -- please correct me if I'm wrong.

EDIT: I think supporting Rails 7.0 is a good idea, but I think you lose the ability to clear those connections in the other pools.

Due to Gruf::Controllers::Base rewriting the error message, actually the backtrace location was confusing.

Maybe fail! could be fixed to include it in the message, but that is beyond the scope of this PR.

Similar to #208 but for a separate deprecation warning when using multiple roles.

We're using gruf v2.20.1, and still experience the deprecation warning
for `clear_active_connections!`.

```
DEPRECATION WARNING: `clear_active_connections!` currently only applies to connection pools in the current role (`reading`).
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 block in call at gruf/lib/gruf/interceptors/active_record/connection_reset.rb:32)>
```

This is caused by rails/rails#45924.

~~If you're still supporting Rails < 7.1, then we should change this to
use `ActiveRecord::Base.current_role`, but I thought your goal was to
clear any and all active connections -- please correct me if I'm
wrong.~~

EDIT: I think supporting Rails 7.0 is a good idea, but I think you lose
the ability to clear those connections in the other pools.

Due to Gruf::Controllers::Base rewriting the error message, actually the
backtrace location was confusing.

Maybe `fail!` could be fixed to include it in the message, but that is
beyond the scope of this PR.
@zzak zzak force-pushed the connection-handler-deprecation branch from 54331d3 to 7875c50 Compare November 21, 2024 07:13
@zzak zzak changed the title Clear all connection pools active connections Fix clear_active_connections! with no argument deprecation warning Nov 21, 2024
@zzak
Copy link
Author

zzak commented Nov 21, 2024

Sorry I just saw #211 but I think this PR is better because specs are passing and doesn't break backwards compatibility.

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

Successfully merging this pull request may close these issues.

1 participant