-
Notifications
You must be signed in to change notification settings - Fork 121
Use external url for query routing history #693
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
Use external url for query routing history #693
Conversation
|
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
1 similar comment
|
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
56701b6 to
9af7eb5
Compare
|
Big +1 on this, we actually just finished an internal implementation of this only a couple of weeks ago that we have been planning to open source. cc @felicity3786 can you help collaborate on this? |
felicity3786
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.
Overall LGTM!
Internally our implementation is a more "normalized" approache, we keep query_history without external_url, and join the gateway_backend to get it at the read time. It would leads to some potential mismatch if the gateway_backend table got updated, but no schema migration needed.
I feel in this PR, it's handled cleaner and simpler. Although there will be risk of "stale" data like if admins rename external_url, but given query_history will be purged periodically I don't think it would be a very big concern.
cc @xkrogen
gateway-ha/src/main/java/io/trino/gateway/ha/router/RoutingManager.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/handler/RoutingTargetHandler.java
Show resolved
Hide resolved
Agree that this could be a concern, but it applies even with the |
Chaho12
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.
Can you update the docs on explaning difference between RoutedTo and ExternalURL? Adding purpose of why 2 url exists would be great.
As you have noticed, external URL was not used at all before.
|
Added documentation on two URLs, purposes and example for the same. cc: @Chaho12 |
gateway-ha/src/main/java/io/trino/gateway/ha/handler/RoutingTargetHandler.java
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/handler/RoutingTargetHandler.java
Show resolved
Hide resolved
vishalya
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.
Thanks for filling the gap @raj-manvar. Could you also please add some unit tests in TestHaGatewayManager
- default value and setting explicit values
- towards cache hits and misses
gateway-ha/src/main/java/io/trino/gateway/ha/router/RoutingManager.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/QueryHistoryManager.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/RoutingManager.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/RoutingManager.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/router/TestExternalUrlQueryHistory.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/router/TestExternalUrlQueryHistory.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/router/TestExternalUrlQueryHistory.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/router/TestExternalUrlQueryHistory.java
Outdated
Show resolved
Hide resolved
vishalya
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.
Approved.
Does it good to the rest of reviewers before I merge it?
Yes, please don't merge this PR yet. |
ebyhr
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.
Please squash commits and separate commits into "Use external url for query routing history" and other style changes.
gateway-ha/src/test/java/io/trino/gateway/ha/router/TestExternalUrlQueryHistoryMySql.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/router/TestHaGatewayManager.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/router/BaseExternalUrlQueryHistoryTest.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/router/BaseExternalUrlQueryHistoryTest.java
Outdated
Show resolved
Hide resolved
682b757 to
d4de4c1
Compare
|
Please rebase on main to resolve conflicts. |
8ce6366 to
2ce79b9
Compare
|
Thanks @ebyhr for the help & feedback! I have rebased with main branch and also squashed all commits into a single commit |
ebyhr
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.
use external url for query routing history
Please capitalize the commit title
https://trino.io/development/process.html#pull-request-and-commit-guidelines-
gateway-ha/src/main/java/io/trino/gateway/ha/router/QueryHistoryManager.java
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/router/TestExternalUrlQueryHistoryPostgresql.java
Outdated
Show resolved
Hide resolved
2ce79b9 to
475974b
Compare
Thanks! I'll be careful for future commits. Updated current MR commit messages. |
475974b to
5f41101
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.
do we now need mapping[backend.proxyTo] = backend.name;? i think we can now remove that part in this code
for (let index = 0; index < data.length; index++) {
const backend = data[index] as BackendData;
mapping[backend.name] = backend.proxyTo;
mapping[backend.proxyTo] = backend.name;
mapping[backend.externalUrl] = backend.name;
}
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 think it's still used in getting the backend Name from backendUrl at https://github.com/trinodb/trino-gateway/blob/main/webapp/src/components/history.tsx#L125
It's also getting used at https://github.com/trinodb/trino-gateway/blob/main/webapp/src/components/history.tsx#L99, but we can replace this usage with just b.name ?
We could remove the remaining two mapping ( backend.name -> proxyTo and externalUrl -> name ), should we do it as part of this pull request though, as it's not strictly related to this change ? or create a separate 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.
A separate PR sounds better :) Thx for checking logic.
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.
Thanks, I created #711 so that we don't miss this.
Chaho12
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.
I think you misunderstood ebyhr comment on capitalizing commit message. We only capitalize the first letter of the subject line.
e.g) Use external URL for query routing history, Remove inferred types and this references
5f41101 to
1fbf355
Compare
Ah thanks okay. I updated the commit messages accordingly. |
|
@ebyhr Does this good look to merge now ? |
Chaho12
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 👍
andythsu
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.
🚀 !
|
Will rebase and merge in few hours if you don't have any further comments @ebyhr :) |

Description
Use external url field for query routing history page
Additional context and related issues
The backendUrl used by Trino gateway may not be accessible for users, instead the external url field is used to indicate the hostname that's accessible by Trino users.
For example, when hosted on Kubernetes, it's common to use Kubernetes Service for inter apps communication like between Gateway and Trino clusters, in such cases the hostname used by Gateway would be something like
service-name.namespace.svc.cluster.localwhich is only accessible from within the Kubernetes cluster.#81 is relevant issue with other discussion points.
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: