Closed rdlrt closed 1 month ago
Duplicate of #699
@wolfgangwalther - While title sounds similar, isnt the linked issue more about COMMIT of transaction in progress rather than connection itself being open in DB (as part of connection pool)?
The linked issue deals with the same problem and has multiple suggestions on how to solve it:
So, yes, a duplicate.
Environment
Description of issue
When a client cancels a connection, the underlying query continues to run on PostgREST db pool (atleast until reaching it's timeout). This gives a potential to easily (knowingly/unknowingly) DDoS an instance by exhausting it's pool if a query is identified that may take a while to run.
While this might be an expected behaviour from db pool and solution there would be nice, in absence of such a solution - an ability on PostgREST layer (perhaps could be a time interval to cleanup connections without client) would be useful. This would allow the security rules at proxy layer to step in and properly terminate unexpectedly wrong running queries, while disconnected clients are cleaned up at source itself
To test:
pg_stat_activity
)(PS: Working against db pool max session timings isnt applicable as there could be legit cases where an exposed query could run for 5 minutes, while most should finish in < 5s, the control for this can be done on proxy layer as long as cancelled connection is shutdown on postgres DB)