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

Timeout seems to not work on long running queries #521

Closed
1 task done
mkay1375 opened this issue Jan 22, 2025 · 1 comment
Closed
1 task done

Timeout seems to not work on long running queries #521

mkay1375 opened this issue Jan 22, 2025 · 1 comment

Comments

@mkay1375
Copy link

mkay1375 commented Jan 22, 2025

Expected behavior

If executing a query takes more time than request_timeout, it should be terminated with a "Timeout Exception".

Actual behavior

The execution is continued until the Trino server responds.

Steps To Reproduce

Create a connection:

from trino.dbapi import connect

connection = connect(
    host="some-trino-host",
    port="443",
    http_scheme="https",
    request_timeout=1.0
)

Execute a long running SQL which takes more than 1 second:

cur = connection.cursor()
cur.execute("SOME LONG RUNNING SQL")

Log output

No response

Operating System

macOS 15.2 (dev), Debian GNU/Linux 12 (bookworm) (prod)

Trino Python client version

0.330.0

Trino Server version

466

Python version

3.12.3 (dev), 3.12.8 (prod)

Are you willing to submit PR?

  • Yes I am willing to submit a PR!
@hashhar
Copy link
Member

hashhar commented Jan 30, 2025

the request_timeout there is the HTTP request timeout passed to Requests library. i.e. no SINGLE http request should take longer than that.

A single Trino query ends up with multiple HTTP requests. Once you submit query the client keeps polling the server periodically so as long as the server replies within 1 second the timeout will never be exceeded.

If you want to limit how long the query should run it's controllable via the session property query_max_execution_time (see https://trino.io/docs/current/admin/properties-query-management.html#query-max-execution-time). So you can set the session property on the connection/cursor to fail all queries that run longer than 1s for example.

@hashhar hashhar closed this as completed Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants