This project is archived and is in readonly mode.

#5253 ✓wontfix
Jaroslaw Zabiello

Rails 3.0 RC cannot capture exception when database goes down!

Reported by Jaroslaw Zabiello | July 30th, 2010 @ 07:01 PM

This is serious error because does not allow for creating self healing applications.

When database MySQL goes down, Rails is going down together! There is no way to avoid default error message on the screen and to capture the exception. This problem happens even if I there were not created any models (but configure/database.yml was pointing to the database)

Rails' methods like "rescue_from" are useless over here because the exception is not propagated to higher layers of the framework. So Rails application raises exception which CANNOT be captured by any controller! This behaviour resembles nasty PHP fatal error. I hope it will be fixed before final release.

Comments and changes to this ticket

  • Jaroslaw Zabiello
  • Kane

    Kane August 1st, 2010 @ 02:21 PM

    i found similar issues as i wrote some workers with the nanite gem and activerecord
    and found myself hacking PostgreSQLAdapter AbstractAdapter and ConnectionPool..

    best of all was that there is a ActiveRecord::ConnectionNotEstablished but its only used when no connection could be established at the beginning. If the connection is lost any time later PostgreSQLAdapter throws a PGError and AbstractAdapter simply converts this in a StatementInvalid exception.

  • Lawrence Pit

    Lawrence Pit August 3rd, 2010 @ 04:05 AM

    The easiest way to go about this is to create your own middleware, and insert it before the ActiveRecord::QueryCache middleware in your application.rb. This middleware can catch the exception, rescue and do the self-healing bit.

  • Rohit Arondekar

    Rohit Arondekar October 7th, 2010 @ 06:33 AM

    • State changed from “new” to “wontfix”
    • Importance changed from “” to “Low”

    I agree with Lawrence.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>