On Thursday, April 16, 2015 at 3:50:02 AM UTC-7, Roman Snitko wrote: > > Thank you, I've read the docs about this extension and thought it might be > reasonable to suggest an improvement to it. From the docs: > > As checking connections for validity involves issuing a query, which is >> potentially an expensive operation, the validation checks are only run if >> the connection has been idle for longer than a certain threshold > > > Wouldn't it then make sense have a single point of entry - a method > through which all DB requests are issued - in which we catch the said > exception and then reconnect if needed? This would spare us the unnecessary > DB request in the case when connection is valid. No? >
As you've seen, Sequel already rescues disconnect exceptions and reconnects if needed, though it does reraise the disconnect exceptions. Sequel does not automatically retry, as there is no way for Sequel to ensure that what is being retried is idempotent. The connection validator checks the validity of the connection before making the connection available to the user's code, so it can ensure the connection is valid before it is used. I consider approaches that rescue exceptions that could be raised by users code and retrying them dangerous, though if you are using a transaction, Sequel does support that: http://sequel.jeremyevans.net/rdoc/files/doc/transactions_rdoc.html#label-Automatically+Restarting+Transactions Thanks, Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
