-
Notifications
You must be signed in to change notification settings - Fork 85
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
Show RoutingGroup info in query history #607
base: main
Are you sure you want to change the base?
Conversation
f57f2ad
to
d23d058
Compare
d23d058
to
ce90b2f
Compare
{ | ||
Optional<String> previousBackend = getPreviousBackend(request); | ||
String clusterHost = previousBackend.orElseGet(() -> getBackendFromRoutingGroup(request)); | ||
// This falls back on adhoc routing group if no routing group can be determined | ||
String routingGroup = routingGroupSelector.findRoutingGroup(request).orElse("adhoc"); |
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.
moving this call out of the orElseGet
will cause the routing logic to be triggered for every incoming request, including those containing query IDs. Please revert
*/ | ||
package io.trino.gateway.ha.handler; | ||
|
||
public record RoutingDestinationInfo(String group, String clusterUri) {} |
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.
It would expand the scope of this change, but it seems like a good time to add some audibility on which rules were triggered. For example, you could have RoutingDestinationInfo(String group, String clusterUri, List<String> rulesFired)
, where rulesFired
would contain the names of all rules who's condition evaluated to true
. We can chat about this offline
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.
Should this be a simple String
instead of List<String
since only the first matching rule gets triggered?
*/ | ||
package io.trino.gateway.ha.handler; | ||
|
||
public record RoutingDestinationInfo(String group, String clusterUri) {} |
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.
Can clusterUri
be
URIinstead of a
String`?
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.
Yep
gateway-ha/src/main/java/io/trino/gateway/proxyserver/ProxyRequestHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/resources/mysql/V2__add_routingGroup_to_query_history.sql
Outdated
Show resolved
Hide resolved
@@ -85,11 +85,11 @@ void testByRoutingGroupHeader() | |||
// If the header is present the routing group is the value of that header. | |||
when(mockRequest.getHeader(ROUTING_GROUP_HEADER)).thenReturn("batch_backend"); | |||
assertThat(RoutingGroupSelector.byRoutingGroupHeader().findRoutingGroup(mockRequest)) | |||
.isEqualTo("batch_backend"); | |||
.contains("batch_backend"); |
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 need to change this?
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.
changing this because findRoutingGroup
returns an Optional<String>
now
String clusterHost = previousBackend.orElseGet(() -> getBackendFromRoutingGroup(request)); | ||
// This falls back on adhoc routing group if no routing group can be determined | ||
String routingGroup = routingGroupSelector.findRoutingGroup(request).orElse("adhoc"); | ||
String user = request.getHeader(USER_HEADER); |
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.
This may not be always true, especially in case of bearer tokens (JWT). But I see that this logic is from before and it's not newly added as a part of the PR.
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.
We can take care of this in a different PR
gateway-ha/src/main/java/io/trino/gateway/ha/handler/RoutingDestinationInfo.java
Outdated
Show resolved
Hide resolved
Let us know when you need another review cycle @andythsu |
cb61497
to
8d6609b
Compare
Optional<String> previousCluster = getPreviousCluster(queryId, request); | ||
RoutingDestination routingDestination = previousCluster.map(cluster -> { | ||
String routingGroup = queryId.map(routingManager::findRoutingGroupForQueryId) | ||
.orElse("adhoc"); |
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.
@willmostly in the case where previousCluster
is found but queryId
is not found (i.e., cookie-based routing), how should we handle the value for routing group?
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 👍
I notice that if two routing groups have same proxyTo url, then history page shows wrong routedTo(Name) too. Have you seen this happen? |
@Chaho12 yes I'm aware of this. The reason is because we don't store |
Also I think we should probably change the language here to match the column names in db to make things consistent... Or at least call it a different name because it's weird to have two |
I agree.. was thinking simply like Btw while I was looking code I notice that not only Name but also the issue is with the data that gets overwritten when proxyTo is not unique. |
e8e492d
to
4157116
Compare
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: asu80.
|
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
Description
It is useful to show what routing group a request is being routed to because if two routing groups have the same
routedTo
url, it will show the wrong information on the history pageOld:

New:

Additional context and related issues
Release notes
( ) This is not user-visible or is docs only, and no release notes are required.
(X) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text: