Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Rails 3.0 RC cannot capture exception when database goes down!

#5253

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.

http://gist.github.com/500875

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

State: wontfix
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Jaroslaw Zabiello
  2. Kane
    Kane

    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.

    August 1st, 2010 @ 02:21 PM

  3. Lawrence Pit
    Lawrence Pit

    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.

    August 3rd, 2010 @ 04:05 AM

  4. Rohit Arondekar
    Rohit Arondekar
    • State changed from new to wontfix
    • Importance changed from to Low

    I agree with Lawrence.

    October 7th, 2010 @ 06:33 AM