Release ActiveRecord connections properly on rack timeout
collimarco opened this issue · 1 comments
collimarco commented
Suppose that an ActiveRecord query takes too long (e.g. 10 minutes). Rack Timeout aborts the request (e.g. after 15 seconds) and the Puma thread is free to serve other requests. That's correct.
However after several failed requests (terminated by rack timeout), this is what we start getting:
ActiveRecord::ConnectionTimeoutError: could not obtain a connection from the pool within 5.000 seconds (waited 5.000 seconds); all pooled connections were in use
This also affects normal requests and our service go down.
How can we make sure that the ActiveRecord connection is freed when a timeout occurs?