This project is archived and is in readonly mode.
MySQL adapter doesn't reconnect on lost connection
-
Cheah Chu Yeow
I've had this happen to me before in production on edge Rails awhile back. I'm not sure why the old behavior was kicked out though, but in practice it definitely doesn't reconnect all the time.
And yup I can confirm that the LOST_CONNECTION_ERROR_MESSAGES constant is not being used anywhere in AR code.
-
Michael Koziarski
The retry-magically code was removed as it was dangerous. You could easily end up resubmitting an insert statement and duplicating data.
However the dispatcher in rails pre-verifies connections in production mode too, which version are you seeing this with?
-
Esad Hajdarevic
This was in 2.1.2 - is the dispatcher pre-verifying connections 2.2 or is it already in 2.1.x?
-
Michael Koziarski
The verification in 2.1 has an optimisation that you might be hitting:
verify_active_connections in connection_specifications.rb uses a timeout. Make sure you haven't set that:
cattr_accessor :verification_timeout, :instance_writer => false @@verification_timeout = 0But the logic is:
# Lazily verify this connection, calling <tt>active?</tt> only if it hasn't # been called for +timeout+ seconds. def verify!(timeout) now = Time.now.to_i if (now - @last_verification) > timeout reconnect! unless active? @last_verification = now end endSo that should be working fine. In 2.2 we remove that setting and just always verify the connection.
-
CancelProfileIsBroken
- State changed from new to resolved
Optional reconnect: key added from #1838 Add reconnect:false to generated database.yml for MySQL