martin icon indicating copy to clipboard operation
martin copied to clipboard

add a proper way to handle long-running and interrupted queries

Open stepankuzmin opened this issue 7 years ago • 1 comments

Martin may become unresponsive while PostgreSQL is handling a lot of long-running SQL queries. Some frontends like Nginx may also cancel requests based on timeout, but these requests might still be running as queries in PostgreSQL.

We need a way to set a timeout for such requests, so we can cancel queries in the PostgreSQL.

stepankuzmin avatar Oct 06 '18 17:10 stepankuzmin

There might be a way to detect when the connection is dropped -- similar to how it is described for the Axum framework here. If the connection is indeed dropped by the fetch API signal, we might be able to utilize the Tokio-postgres CancelToken

Something like this:

let conn = get_connection(&self.pool).await?;
let cancel_token = conn.cancel_token();
let cancel = cancel_token.cancel_query(tls_info);

nyurik avatar Nov 27 '22 02:11 nyurik