You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since rails 7.1, executing with a disconnected Mysql2Adapter no longer raises ConnectionNotEstablished.
Steps to reproduce
in my project, conn.disconnect! is used to disconnect the connection after detecting a temporary database connection failure.
(e.g. failover / connection failure due to restart...etc)
Until Rails 7.0.8, when using a disconnected connection, ActiveRecord::ConnectionNotEstablished would be raised and conn.execute would fail.
(I have a mechanism to try to reconnect using this ConnectionNotEstablished Error)
Since Rails 7.1.0, conn.execute does not raise an error despite being disconnected.
Perhaps this change was made by this PR ( #44591).
Are there any plans to modify it to raise the error?
Explicit disconnect! is an edge case, but generally I think this is expected behaviour -- if we aren't connected, we're trying to do something that requires us to be connected, and we know how to connect... it seems reasonable that we'd do the thing that should work.
We could specifically track the fact that we've manually disconnected and therefore should not auto-reconnect, but it mostly just seems like avoidable complication.
I'm open to being convinced, though.. is there a compelling use for being able to leave the connection broken? (You describe error recovery & reconnection code in your app -- does Active Record's new automatic reconnection behaviour not work for you?)
Since rails 7.1, executing with a disconnected Mysql2Adapter no longer raises ConnectionNotEstablished.
Steps to reproduce
in my project, conn.disconnect! is used to disconnect the connection after detecting a temporary database connection failure.
(e.g. failover / connection failure due to restart...etc)
Until Rails 7.0.8, when using a disconnected connection, ActiveRecord::ConnectionNotEstablished would be raised and conn.execute would fail.
(I have a mechanism to try to reconnect using this ConnectionNotEstablished Error)
Since Rails 7.1.0, conn.execute does not raise an error despite being disconnected.
Perhaps this change was made by this PR ( #44591).
Are there any plans to modify it to raise the error?
Expected behavior
ConnectionNotEstablished is raised in case of execute using a disconnected connection.
Actual behavior
The execute method does not raise an error.
execute completes successfully and returns Mysql::Result.
System configuration
Rails version: 7.1.1
Ruby version: 3.2.2
The text was updated successfully, but these errors were encountered: