I am trying show controller specific pages in my rails app when the
database connection goes away. I do this by catching the Mysql::Error in
the rescue_action method and rendering appropriate pages. When the mysql
service alone is stopped , i get the Mysql::Error exception really
quickly and i could render the pages without any delay.
But when the server itself is shut down, rails takes 3 mins to throw the
Mysql::Error and after 5-6 request the whole website becomes
unresponsive.
I tried to figure out, which method in rails framework takes such a long
time , when the mysql server is shut down. It was a method
connection.real_connect (in the active record mysql_adapter file),which
took 3 mins to return with an exception when there is no connection with
the database server.
so i decided to timeout out this method using systemTimer gem. This
monkey patch worked perfectly, when i start the website with database
connection and immediately shutdown the database server.
But when i start the website with database, and access the website for
sometime and then shut down the database server, it doest work at all.
and the whole website becomes unresponsive as before. I wonder what is
the difference between the two scenarios.
I think i need to know more in detail about how rails handle database
connection . how it reacts when the database connection goes off. so
that i could identify exact places where i can put monkey patches and
make it work for my specif requirement. I havent seen any relevant
article explaining this.
Any help will be very useful for me
Thanks,