Hi,

I have an interesting issue with one of my Ruby+Sequel web apps. The app is 
very infrequently used, and the (MySQL) dba employs fairly aggressive 
connection pruning. This means that  connections in Sequel's db pool are 
almost always invalidated when a request comes through (because MySQL has 
disconnected them). My immediate thought was to reduce the max_connections 
option (Sequel.connect) to 1, but I have a feeling 
(confirmed?<https://groups.google.com/d/topic/sequel-talk/yb_u0uDiCDk/discussion>
 I've 
been lazy and not tested for myself) doing so would mean the app would only 
have 1 active db connection.

So my question: can I configure Sequel to not pool connections, but still 
ensure each request can access a (freshly minted as required) db 
connection, perhaps with an upper limit on maximum active connections? Am I 
just getting confused between db.max_connections vs db.pool.max_connections?

I'm running Sequel v3.41.0.

I connect to my MySQL database in a fairly basic manner:

> Sequel.connect(jdbc:mysql://localhost:3306/stats?user=test&zeroDateTimeBehavior=convertToNull,
>  :max_connections 
> => 10)

 
Using the db connection is achieved by yielding it, and 
catching Sequel::DatabaseDisconnectError to automatically retry (somewhat 
modified here for simplicity):

>     5.times do
>       begin
>         return yield(@db || Sequel.connect...)
>       rescue Sequel::DatabaseDisconnectError => e
>         Log.info("Connecting to the database failed.  Retrying...")
>
        sleep(2) 

      end
>     end



-- 
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/-/xRGys-4-uRQJ.
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