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

5.0.0.rc1: Regression: Unable swap to a custom connection pool and back to AR::Base pool after #24844 #24959

Closed
jrafanie opened this issue May 10, 2016 · 2 comments

Comments

@jrafanie
Copy link
Contributor

Steps to reproduce

See the failing AR test case and output. I wasn't sure where the fix/test for this should live but I believe the test case is valid in terms of testing how remove_connection should undo what establish_connection does.

Expected behavior

klass2.remove_connection should remove any custom connection pool and allow the superclass's pool to be used by resetting caches/ivars indicating a custom pool is to be used.

Actual behavior

#24844's refactoring changed behavior when you configure a custom connection and remove it. Any subsequent calls to connection from that model will fail to find a pool and NOT fallback to the superclass' pool.

klass2.establish_connection(custom_config)
# code
klass2.remove_connection
klass2.connection  # raises ActiveRecord::ConnectionNotEstablished: No connection pool with id klass2 found

Workaround 1

klass2.establish_connection(custom_config)
# code
klass2.remove_connection
klass2.connection_specification_name = "primary" # this gets us back the primary pool
klass2.connection

Workaround 2

klass2.establish_connection(custom_config)
# code
klass2.remove_connection
klass2.establish_connection # this gets us back the primary pool
klass2.connection

Neither of these changes were needed prior to #24844.

System configuration

Rails version: 5.0.0.rc1

Ruby version: 2.2.4

@arthurnn
Copy link
Member

d6f3ad7 should fix the issue..
thanks for reporting , and let me know if it works.

arthurnn added a commit that referenced this issue May 11, 2016
remove_connection

When calling `remove_connection` on a model, we delete the pool so we also
need to reset the `connection_specification_name` so it will fallback to
the parent.
This was the current behavior before rails 5, which will fallback to the
parent connection pool.

[fixes #24959]

Special thanks to @jrafanie for working with me on this fix.
@arthurnn
Copy link
Member

backported to 5-0-stable 6458610

arthurnn added a commit that referenced this issue May 11, 2016
remove_connection

When calling `remove_connection` on a model, we delete the pool so we also
need to reset the `connection_specification_name` so it will fallback to
the parent.
This was the current behavior before rails 5, which will fallback to the
parent connection pool.

[fixes #24959]

Special thanks to @jrafanie for working with me on this fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants