verifying connections before first use #545
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.