Skip to content

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.

1 participant