Skip to content

feat(db): Add make_statement_timeout_budget - #125142

Draft
kcons wants to merge 1 commit into
masterfrom
kcons/tweakpass
Draft

kcons wants to merge 1 commit into
masterfrom
kcons/tweakpass

Conversation

@kcons

@kcons kcons commented Sep 21, 2026

Copy link
Copy Markdown
Member

Query timeouts are valuable for keeping resource consumption predictable, but for looping or condition code it is hard to apply them effectively. Statement timeouts are per statement, so "let these code below run for up to 10s" is hard to represent with them.
This adds make_statement_timeout_budget, which makes it possible to do:

db_timeout = make_statement_timeout_budget(timedelta(seconds=10))

for item in items:
    with db_timeout():
        perform_query(item)

and know that the cumulative query time isn't going to significantly exceed 10 seconds.
It does introduce the costs of transactions and additional statements, but in the context of behavior that may take seconds, that's usually not a major concern.

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Sep 21, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant