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

verifying connections before first use #545

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

pbrumm
Copy link

@pbrumm pbrumm commented Jan 3, 2020

rails connection pool does this by default when checking out from pool.
https://github.com/rails/rails/blob/v5.0.7.2/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb#L364
when the db restarts this only gets hit for the primary connection and not any that use the model.using( which then fail and continue to fail until instance is restarted.

this is the best I could come up with to get something equivalent as I don't see where to clear Thread.current[] vars when the connection is checked back into the pool.

the RequestStore gem does this for you in rails and there is a sidekiq instance as well to help with that.

this is going through testing on our side and if everything works on production then I will put in an update.

sometimes the second calls would return different connection and this
would cause issues with the reconnecting.
this does introduce a dependency on RequestStore gem to work.
but it also falls back
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.

None yet

1 participant