Em quarta-feira, 24 de outubro de 2012 10h49min46s UTC-2, Rodrigo Rosenfeld 
Rosas escreveu:

>
>
> Em terça-feira, 23 de outubro de 2012 22h04min13s UTC-2, Rodrigo Rosenfeld 
> Rosas escreveu:
>>
>> Em terça-feira 23 outubro 2012, às 20:28:47, Jeremy Evans escreveu: 
>> > On Tuesday, October 23, 2012 9:09:25 AM UTC-7, Jeremy Evans 
>> wrote: 
>> > > 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. 
>> > 
>> > The code to check connections for validity has been pushed.  I have 
>> the 
>> > extension that automatically checks connections for validity on pool 
>> > checkout written and apparently working based on the integration- 
>> level 
>> > tests, but I still need to add documentation and extension-level 
>> tests.  I 
>> > expect that the extension will be pushed to the master branch 
>> sometime 
>> > tomorrow. 
>>
>> Wow! This is really great news! Thank you so much! 
>>
>
> By the way, I hope this will help me with another issue I'm having. 
> Yesterday I had to restart the Rails apps because of EBADF (Bad File 
> Descriptor) errors in a Sequel line like "User[id]". For some reason we're 
> having some troubles with our connection to the PG server even when we 
> don't restart the server. :(
>

Another thing to consider is removing all connections from the pool when a 
connection error is detected in one of them. Most likely it will happen 
with the other ones as well. For instance if you restart the PG server, all 
connections will become invalid. But still Sequel calls will fail 50 times 
consecutively if there are 50 connections in the pool. Maybe there should 
be an option to clear the pool once it has been detected some problem in 
any of the connections. Maybe that could be the default behavior. Does it 
make sense?

For example, suppose you have a 10 servers cluster and each one has a pool 
size of 50. There will be 500 failed requests after restarting a PG 
database or some similar issue that could cause the connections to be 
killed.

-- 
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/-/TFyhokJykoIJ.
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