Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add query timeouts using context cancellation #80

Merged
merged 1 commit into from
Sep 1, 2023
Merged

Conversation

amotl
Copy link
Member

@amotl amotl commented Aug 31, 2023

About

In order to improve the situation with GH-33, this patch enables timeouts for read and write operations, and adds the capability to configure the timeout values, defaulting to five seconds. The corresponding configuration settings are read_timeout and write_timeout.

Background

In production applications, it is always preferred to have timeouts for all queries: A sudden increase in throughput or a network issue can lead to queries slowing down by orders of magnitude.

Slow queries block the connections that they are running on, preventing other queries from running on them. We should always set a timeout after which to cancel a running query, to unblock connections in these cases.

-- https://www.sohamkamani.com/golang/sql-database/#query-timeouts---using-context-cancellation

The corresponding configuration settings are `read_timeout` and
`write_timeout`.
@amotl amotl force-pushed the amo/read-write-timeout branch from b334534 to 30fb216 Compare September 1, 2023 19:30
@amotl amotl merged commit 9e76022 into main Sep 1, 2023
@amotl amotl deleted the amo/read-write-timeout branch September 1, 2023 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants