Skip to content

How to set query timeout? #1970

Answered by abonander
ysn2233 asked this question in Q&A
Jul 13, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

You can time-out a query using tokio::time::timeout or async_std::future::timeout but that will only cancel the wait for the query response on the client-side. The server may still be left in a busy state calculating the query results, so the next query on the connection will have to wait for the server to finish the previous one.

Additionally, cancelling an in-flight query might break the connection as we have issues with cancellation still. Postgres and SQLite should be able to handle cancellation okay, but MySQL doesn't (#563). If you're using Pool it will check if the connection is broken and close it so it doesn't get used again.

All that said, I'd recommend setting a timeout on the …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@airekans
Comment options

Answer selected by ysn2233
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants