On Thursday, August 23, 2012 6:04:57 AM UTC-7, azi wrote:
>
> I need to do some database insert operation and there are cases when that 
> the db connection was not used for the period that's set as wait_timeout at 
> the mysql server. I don't want to change that timeout but I want my write 
> to succeed at the same time. Is there a way to put the DB.insert statement 
> in begin...rescue...end block so that the insert is guaranteed to succeed.
> "rescue Sequel::DatabaseDisconnectError" I assume should be the rescue 
> statement but I am not sure of the complete block.
>

You can use retry, but you should be very sure what you are retrying is 
idempotent.

The better solution is to make sure your database connections don't exceed 
wait_timeout.  The best solution is just setting a very high wait_timeout.  
If you don't want to do that, the usual solution for low traffic apps is to 
use cron or something similar to make sure the connection is used more 
often than wait_timeout.

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