[Mongrel] rails app breaks after pg restart

Jeroen Houben jeroen at supercool.nl
Wed Oct 25 13:25:11 EDT 2006


Wilson Bilkovich wrote:
> On 10/25/06, Jeroen Houben <jeroen at supercool.nl> wrote:
>> Hi,
>>
>> Disclaimer: I'm pretty sure this isn't a mongrel issue, as I'm pretty
>> sure I had the same problem back in the lighty-fastcgi days..
>>
>> After a postgres restart, my rails apps crash with this error:
>>
>> ActiveRecord::StatementInvalid (PGError: FATAL:  terminating connection
>> due to a
>> dministrator command
>> server closed the connection unexpectedly
>>          This probably means the server terminated abnormally
>>          before or while processing the request.
>> : SELECT count(*) AS count_all FROM matches ):
>>
>> Strange thing is, after a do a page refresh everything works again. It's
>> like the connections are re-established and all is well. But I have to
>> do it for each application that is running, really annoying.. Does
>> anybody know what is going on here?
>>
> 
> Yep. The Postgres connection adapter in Rails doesn't have the 'smart
> reconnect' code that was added to the Oracle adapter.
> The Oracle one contains a list of all the possible 'safe to reconnect'
> OCI error codes, and just goes ahead and does it if it encounters one
> of those.
> 
> It would probably be fairly straightforward to add that feature to the
> postgres adapter.

Right. Thanks for the update. I'd have a go at adding it myself but I 
guess it's written in C, that rules me out :(

Jeroen


More information about the Mongrel-users mailing list