-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Handle long running queries in DirectTrinoClient #26371
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
Handle long running queries in DirectTrinoClient #26371
Conversation
lukasz-stec
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Please add a test with a small query.client.timeout and a query running longer
core/trino-main/src/main/java/io/trino/client/direct/DirectTrinoClient.java
Outdated
Show resolved
Hide resolved
kokosing
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to test it it works? For example you can have a query that takes 5 seconds to complete and query.client.timeout set to 1 second, and see that you are able to run such query.
core/trino-main/src/main/java/io/trino/client/direct/DirectTrinoClient.java
Show resolved
Hide resolved
dbba1b5 to
1245cde
Compare
kokosing
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
% comments
testing/trino-tests/src/test/java/io/trino/client/direct/TestDirectTrinoClient.java
Show resolved
Hide resolved
testing/trino-tests/src/test/java/io/trino/client/direct/TestDirectTrinoClient.java
Outdated
Show resolved
Hide resolved
testing/trino-tests/src/test/java/io/trino/client/direct/TestDirectTrinoClient.java
Outdated
Show resolved
Hide resolved
1245cde to
3a9fe4a
Compare
lukasz-stec
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
testing/trino-tests/src/test/java/io/trino/client/direct/TestDirectTrinoClient.java
Outdated
Show resolved
Hide resolved
|
Ping me when it is green |
8ff4dbd to
b4da9b4
Compare
When a query being executed by DirectTrinoClient takes longer than the query.client.timeout, the query is then canceled. This client is used in some cases when executing queries from within the coordinator
b4da9b4 to
8d4cdb9
Compare
|
Thanks! |
| catch (TimeoutException e) { | ||
| // continue waiting until the query state changes or the exchange client is blocked. | ||
| // we need to periodically record the heartbeat to prevent the query from being canceled | ||
| dispatchQuery.recordHeartbeat(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I’ve seen abandoned queries before, especially when the cluster was under high pressure — it have been the actual cause back then
Description
When a query being executed by DirectTrinoClient takes longer than the query.client.timeout, the query is then canceled. This client is used in some cases when executing queries from within the coordinator
Additional context and related issues
The
QueryTrackeruses this timeout in itsprivate boolean isAbandoned(T query)method to check it vs the last heartbeat. @lukasz-stec recommended i periodically record a heartbeat while waiting for this future to avoid falling into that case.Release notes
(X) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text: