On Monday, October 22, 2012 6:20:41 PM UTC-7, Rodrigo Rosenfeld Rosas wrote:
>
>
>
> Em segunda-feira, 22 de outubro de 2012 19h34min26s UTC-2, Jeremy Evans 
> escreveu:
>>
>> On Monday, October 22, 2012 11:47:29 AM UTC-7, Rodrigo Rosenfeld Rosas 
>> wrote:
>>>
>>> I had to restart the PostgreSQL service in our database server and the 
>>> Rails apps using Sequel stopped working. 
>>>
>>> Is there a way to instruct Sequel to try to reconnect on such cases? One 
>>> that works both for MRI and JRuby? 
>>>
>>>
>> Sequel should be removing the connections from the pool, reraising the 
>> exceptions, and creating new connections as needed in the future.  So it's 
>> expected that some DatabaseDisconnectErrors will be raised, but Sequel 
>> should recover, assuming that it correctly recognizes the disconnections 
>> (which it should on the postgres and jdbc/postgres adapters).  If that 
>> isn't what you experienced, please try to put together a reproducible test 
>> case and I'll take a look.
>>
>
> But this is a problem for our setup as we have a cluster with a dozen 
> servers and there will be as many reported errors as there are servers in 
> the cluster and all of them end up in our SLA errors log which affects our 
> contract :(
>
> Is there a way of just instructing Sequel to query something like "select 
> 1" before attempting to use the connection? Hibernate has an option to do 
> so and it works. Our application is a mix of a Grails and a Rails app. We 
> only had to restart the Rails servers of the cluster as the Grails ones 
> that used Hibernate with this option enabled didn't experience any issues.
>
> We'd like to be able to do something like with Sequel as well.
>
> Would that be possible?
>

It's actually something I'm planning to implement as a extension very 
soon.  The recently committed refactoring of the database <-> connection 
pool interface is the first step, I need to add code to check connections 
for validity and then an extension that automatically checks connections 
for validity when they are checked out from the pool.

Note that restarting your app servers whenever you restart your database 
server has been the recommended way for a long time.  The extension I'm 
planning to implement is mostly to handle inactive connections in the pool 
that get timed out and disconnected by the database.  If you have control 
over when your database server restarts, it shouldn't be difficult to make 
sure your app servers are restarted at the same time.

Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sequel-talk/-/mZrRf2ilAgoJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to