On Monday, March 30, 2020 at 7:51:59 AM UTC-7, BeeRich33 wrote:
>
> OK, I set my app to not restart for every request, and the same error came 
> up with this inside my database helper:
>
> DB = Sequel.connect('postgres://user1@localhost:5432/dbname1')
> DBN = Sequel.connect('postgres://user1:[email protected]:5432/dbname2')
> DB.extension(:connection_validator)
> DBN.extension(:connection_validator)
>
> Obviously I've implemented it the wrong way.  I was assuming it was behind 
> the scenes with respect to the connection pool, and if there were no pools 
> open (default 60 minutes close time), it would initiate a new connection.  
>
> Is this correct?  What do I have to change for connections to start if the 
> pool is empty and/or all closed?
>

As the documentation for the extension states, it validates connections 
before checkout, and if they aren't valid, it removes them from the pool 
without raising an exception, either using another available connection or 
making a new connection if needed.  However, by default, it only checks if 
the connection has not been used in the last hour.  If you want to validate 
more often (even on every checkout), you can use 
connection_validation_timeout to set a shorter timeout.

By default, Sequel automatically creates connections as needed.  It starts 
with a single connection when you create the Sequel::Database instance, to 
fail early if the connection cannot be made.  It creates additional 
connections any time a request for a connection comes in and there are no 
available connections, up until the maximum number of connections is 
reached.

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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/8d1602eb-2e37-49f4-b854-45922443fc95%40googlegroups.com.

Reply via email to