Fix ActiveRecord :connection incompatibility with serialization libraries #662
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.
As of
0.18.0
via #649, we injected the ActiveRecord adapter object as:connection
into thesql.active_record
, mimicking the behavior of rails/rails#34602 which appears in Rails 6. We did this in order to workaround a performance problem for JRuby, where our previous implementation ofid2ref
was causing issues.There are other 3rd party libraries that serialize the output of this
sql.active_record
event (e.g.meta_request
gem), and the:connection
object we injected is not serializable, causing aSystemStackError
error. It's unclear whether this is a breaking change for Rails 6, such that these libraries should upgrade to be compatible with Rails 6, or just a bug.Either way, we can't mimic this behavior here for users with Rails < version 6, so we need to implement a new strategy. This pull request instead resolves connections by searching connection pools and finding connection configuration that way, as was originally implemented by @guizmaii.
Addresses #661.