When attempting to retrieve a connection in ActiveRecordSubscriber, a loop occurs, eventually leading to ActiveRecord::ConnectionTimeoutError.
In versions of Rails lower than 6, since the payload does not contain a connection, it tries to use ActiveRecord::Base.connection to get the current connection. However, it seems that this causes subscribe! to be called again.
I am not sure if this issue is specific to MySQL. Please refer to the following repository for a reproduction environment:
https://github.com/Iwaide/re_app_for_sentry/
Fix
I have modified the code to search for and retrieve a connection from ActiveRecord::Base.connection_pool.connections.
I am not very familiar with connection management, so I am not entirely confident that this is the appropriate approach. Please make any necessary corrections.
Issue
When attempting to retrieve a connection in
ActiveRecordSubscriber
, a loop occurs, eventually leading toActiveRecord::ConnectionTimeoutError
.In versions of Rails lower than 6, since the payload does not contain a connection, it tries to use
ActiveRecord::Base.connection
to get the current connection. However, it seems that this causessubscribe!
to be called again. I am not sure if this issue is specific to MySQL. Please refer to the following repository for a reproduction environment: https://github.com/Iwaide/re_app_for_sentry/Fix
I have modified the code to search for and retrieve a connection from
ActiveRecord::Base.connection_pool.connections
. I am not very familiar with connection management, so I am not entirely confident that this is the appropriate approach. Please make any necessary corrections.