[Catalyst] Graceful handling of database failure

Matt S Trout dbix-class at trout.me.uk
Sun Jul 20 02:59:19 BST 2008


On Wed, Jul 16, 2008 at 12:57:58PM -0500, mike wrote:
> On Tue, Jun 17, 2008 at 5:27 PM, J. Shirley <jshirley at gmail.com> wrote:
> > On Tue, Jun 17, 2008 at 2:31 PM, Mitchell K. Jackson
> > <mitchell.k.jackson at gmail.com> wrote:
> >> Good afternoon,
> >>
> >> Is there a graceful way for a catalyst app to handle when the database
> >> server goes away?  If this happens while a process is holding open a
> >> database connection it's already been using, there's not even a
> >> database error to the log. The only error is "read data timeout in 40
> >> seconds", and an error 500 to the web browser.
> >>
> >> I would like my app to be able to deliver a  more useful error to the
> >> end user, such as "Lost database connection."  If I can retain control
> >> of the app in this event, I'll have it send me an sms for good
> >> measure.  Any ideas how I could go about this?
> >>
> >> Regards,
> >>
> >> /Mitchell K. Jackson
> >>
> >
> >
> > That's really up to the model you are using.  Catalyst doesn't handle
> > databases :)
> >
> > If you are using DBIx::Class, I'd be surprised if it doesn't do the
> > right thing already.
> >
> > As far as catching the error, make sure that your model throws a
> > proper exception and you can catch that in the end action.
> >
> > Something like this is what I tend to use:
> 
> [snip]
> 
> are you using Catalyst::Plugin::Session::Store::DBIC like he is?  we're
> using code identical to what you suggested, but it doesn't work for
> exceptions generated in finalize_headers.

I think that the exception thrown by the session store should be considered
a bug.

Or at least the whole "exception in engine BLAM" result.

Not entirely sure what the best way is of fixing it though - anybody got
any ideas?

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/



More information about the Catalyst mailing list