-
Notifications
You must be signed in to change notification settings - Fork 66
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
Extract query ID from all kill_query procedure variations #425
base: main
Are you sure you want to change the base?
Extract query ID from all kill_query procedure variations #425
Conversation
0f19b85
to
1ad0e45
Compare
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 fine .. I wish we would not have to mock around for stuff like that but a full integration test seems worse..
gateway-ha/src/test/java/io/trino/gateway/ha/handler/TestQueryIdCachingProxyHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/handler/TestQueryIdCachingProxyHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/handler/TestQueryIdCachingProxyHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/handler/TestQueryIdCachingProxyHandler.java
Outdated
Show resolved
Hide resolved
1ad0e45
to
a8355b6
Compare
a8355b6
to
83760bd
Compare
gateway-ha/src/main/java/io/trino/gateway/ha/handler/ProxyUtils.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/handler/TestQueryIdCachingProxyHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/handler/TestQueryIdCachingProxyHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/handler/TestQueryIdCachingProxyHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/handler/ProxyUtils.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/handler/TestQueryIdCachingProxyHandler.java
Outdated
Show resolved
Hide resolved
9a00f3e
to
95e782a
Compare
gateway-ha/src/main/java/io/trino/gateway/ha/handler/ProxyUtils.java
Outdated
Show resolved
Hide resolved
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.
The regular expression is incorrect in some cases.
95e782a
to
c311199
Compare
Needs a rebase now.. |
c311199
to
e9226b6
Compare
gateway-ha/src/test/java/io/trino/gateway/ha/handler/TestQueryIdCachingProxyHandler.java
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/handler/TestQueryIdCachingProxyHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/handler/TestQueryIdCachingProxyHandler.java
Outdated
Show resolved
Hide resolved
805fd81
to
e805660
Compare
@ebyhr I switched to using the full query parser, which should be resilient to whitespace, comments, the string literals containing the procedure name, etc |
gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/handler/RoutingTargetHandler.java
Outdated
Show resolved
Hide resolved
procedure = Optional.of((Call) node); | ||
procedureArgs = ((Call) node).getArguments(); |
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.
The method name is getNames
. Setting these fields changes doesn't match the naming now. I would recommend moving this logic to ProxyUtils
and reverting changes in this class.
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.
i renamed the method to be more generic. The initial implementation was only concerned with extracting qualified names from SQL, but there is no reason IMO not to extract other information as well. In addition to this specific case of the kill_query
call which contains a query id, the Call
and CallArguments
could be useful for routing logic. For example, perhaps the sync_partition_metadata
procedure should always be run on a specific set of clusters.
gateway-ha/src/main/java/io/trino/gateway/ha/handler/RoutingTargetHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/handler/TestQueryIdCachingProxyHandler.java
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/handler/ProxyUtils.java
Outdated
Show resolved
Hide resolved
e805660
to
6e9842a
Compare
gateway-ha/src/main/java/io/trino/gateway/ha/handler/ProxyUtils.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/handler/ProxyUtils.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/handler/ProxyUtils.java
Outdated
Show resolved
Hide resolved
6e9842a
to
76f2c68
Compare
gateway-ha/src/main/java/io/trino/gateway/ha/config/RequestAnalyzerConfig.java
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/handler/RoutingTargetHandler.java
Outdated
Show resolved
Hide resolved
catch (Exception e) { | ||
log.error(e, "Error extracting query payload from request"); | ||
catch (IOException e) { | ||
log.error(e, "Error reading request body"); |
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.
Why do we suppress IOException here and throw an exception for non string literal argument of kill_query
procedure?
The request.getInputStream()
may contain kill_query
, but it can go to extractQueryIdIfPresent
in case of IOException
, right?
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.
If the request body contains the kill_query
SQL, then I already know at this point that extractQueryIdIfPresent
will not find a query id because Trino doesn't have any endpoints with query id embedded in the path
or queryParams
that accept a POST
. So falling back won't help. If I don't throw on a non-string literal argument, then this request will most likely get routed to a cluster that the target query is not running on, and the user will get a potentially confusing error message back about the query not existing. So throwing on a non-string literal allows us to fail fast with a more meaningful error.
Do you think we should throw on IOException
as well? I was just trying to match the existing behavior, but i'm not sure that it is correct.
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.
Just noting that this has been changed such that the IOException is not suppressed, and is treated as an error. If the gateway can't read the request body, Trino will not be able to either, so there is no reason to forward the request.
76f2c68
to
f4ee990
Compare
gateway-ha/src/main/java/io/trino/gateway/ha/handler/RoutingTargetHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/handler/ProxyUtils.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/handler/ProxyUtils.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/handler/ProxyUtils.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/handler/ProxyUtils.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/handler/ProxyUtils.java
Outdated
Show resolved
Hide resolved
Could you rebase on main to resolve conflicts? |
9e35c95
to
c8fe87d
Compare
c8fe87d
to
131228b
Compare
Description
Trino Gateway attempts to extract the query id from the body of queries using the runtime.kill_query procedure from the system catalog. This adds a test for this functionality.
Additional context and related issues
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: