[Rails] Database Auto-reconnect
Brian Terlson
terl0004 at umn.edu
Sat Feb 12 07:59:19 GMT 2005
Hello all,
I have a Rails application that uses a mySQL database. It runs on the
intranet here, and frequently doesn't get accessed for a span of 8 hours
or more (especially since I'm its sole developer and its not even done
yet). I often run into the following problem: After a period of
inactivity, I try to access any page that references an active record
model, and it errors out. The error message is "Invalid argument: #{any
SQL statement you want here}".
I asked about this on IRC, and thanks to some very helpful folks, the
problem has been narrowed down to the SQL connection timing out after 8
hours and disconnecting, and Rails not re-connecting. This coincides
with the mySQL logs - when the error is thrown above, there is no
activity in the database logs.
Is there a way I can tell Rails to reconnect to the database if the
connection is dropped? This seems like it can't be only a problem I've
run in to... Everyone isn't constantly restarting apache when
developing a site on their own box are they? ;)
Thanks for any help you guys can provide!
-Brian Terlson
More information about the Rails
mailing list