-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Upgrade Glue Client to AWS SDK v2 #17866
Upgrade Glue Client to AWS SDK v2 #17866
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 |
I'm not sure why the original code used the async version of the interface, but we can use the synchronous GlueClient in the new version. |
|
||
<dependency> | ||
<groupId>software.amazon.awssdk</groupId> | ||
<artifactId>http-client-spi</artifactId> |
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 should use apache-client
since we don't need or want async behavior. Please see trino-filesystem-s3
to see how we use it with S3.
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 added a few details in this comment. trino-hive
may not be able to use sync client as mentioned.
Should I convert the one in trino-iceberg
(TrinoGlueCatalog
) to sync ?
plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/AwsSdkUtil.java
Outdated
Show resolved
Hide resolved
/** | ||
* Helper method to handle sync request with async client | ||
*/ | ||
public static <Request, Result> Result awsSyncRequest( |
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 shouldn't be needed if we use GlueClient
.
import software.amazon.awssdk.services.glue.model.UpdateColumnStatisticsForTableRequest; | ||
import software.amazon.awssdk.services.glue.model.UpdateDatabaseRequest; | ||
import software.amazon.awssdk.services.glue.model.UpdatePartitionRequest; | ||
import software.amazon.awssdk.services.glue.model.UpdateTableRequest; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
public class GlueCatalogIdRequestHandler |
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.
Since we're updating all the code, I think it would make more sense to drop this class and set the catalog ID directly when creating the request objects. @ebyhr thoughts?
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.
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.
Correct, the alternative is to update all of the call sites in GlueHiveMetastore
. It looks like most requests of a given type are only made in one place, so the amount of code should be the same (probably fewer lines). The advantage of the GlueCatalogIdRequestHandler
approach is that we guarantee that no places are missed, so perhaps we should leave this alone.
It is unfortunate that the Glue SDK doesn't have a common interface or subclass for Glue requests for the catalog ID methods.
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.
right, have kept it as is.
plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/GlueClientUtil.java
Outdated
Show resolved
Hide resolved
...in/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/GlueCredentialsProvider.java
Outdated
Show resolved
Hide resolved
...ino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/converter/GlueInputConverter.java
Outdated
Show resolved
Hide resolved
@electrum thanks for the review. I am working on addressing the other comments. On this one, I think the async client originally existed because of the TrinoGlueCatalog in iceberg module do not have any such requirements yet, and can work with sync client. I can convert that. |
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 |
That makes sense. Let's change Iceberg to use synchronous, but use async for Hive. I note that the V1 client actually used an executor internally, but with V2 we can use the async client and reduce thread usage (but with higher fixed thread usage and overhead due to Netty). |
1c56b7c
to
a654ea1
Compare
Sure @electrum, changed glue calls in iceberg module to use sync client. |
@ShubhamChaurasia pls rebase on top of |
cc68a9a
to
4343d86
Compare
@findinpath rebased and updated. |
This CR updates the glue client to aws sdk v2. It mainly converts the GlueHiveMetastore and TrinoGlueCatalog used by respectively `trino-hive` and `trino-iceberg` to v2. - The packages have been relocated from com.amazonaws.services.glue to software.amazon.awssdk.services.glue. Creation of clients and requests have been moved to builder pattern. v1 version ``` new DeleteDatabaseRequest().withName(database) ``` v2 version ``` DeleteDatabaseRequest.builder().name(database).build() ``` - In v1 the async client extended the sync client and hence had both the sync and async methods. In v2, the async client only has the async methods which return CompletableFuture. In order to use the async method for a sync call, it needs to be blocked using join() or get(). As this is a common use case the handling has been added as a utility to io.trino.plugin.hive.metastore.glue.AwsSdkUtil. - The request handlers are converted to use the `ExecutionInterceptor` which is used to intercept the request and perform several actions during the lifecycle of the request. - Converting MetricsRequester to MetricsPublisher to collect metrics and store them in GlueMetastoreStats. Some of the metrics have been changed. Below is the result. v1 version ``` select "awsclientexecutetime.alltime.avg", "awsclientexecutetime.alltime.count", "awsrequesttime.alltime.avg", "awsrequesttime.alltime.count", "awsclientretrypausetime.alltime.avg", "awsclientretrypausetime.alltime.count", "awsthrottleexceptions.totalcount", "awsrequestcount.totalcount", "awsretrycount.totalcount", "awshttpclientpoolavailablecount", "awshttpclientpoolleasedcount", "awshttpclientpoolpendingcount" from "trino.plugin.hive.metastore.glue:name=hive,type=gluehivemetastore"; Result: "awsclientexecutetime.alltime.avg","awsclientexecutetime.alltime.count","awsrequesttime.alltime.avg","awsrequesttime.alltime.count","awsclientretrypausetime.alltime.avg","awsclientretrypausetime.alltime.count","awsthrottleexceptions.totalcount","awsrequestcount.totalcount","awsretrycount.totalcount","awshttpclientpoolavailablecount","awshttpclientpoolleasedcount","awshttpclientpoolpendingcount" "505.086064688","125.0","425.98159896799996","125.0","NaN","0.0","0","125","0","5","0","0" ``` v2 version ``` select "awsservicecallduration.alltime.avg", "awsservicecallduration.alltime.count", "awsapicallduration.alltime.avg", "awsapicallduration.alltime.count", "awsbackoffdelayduration.alltime.avg", "awsbackoffdelayduration.alltime.count", "awsthrottleexceptions.totalcount", "awsrequestcount.totalcount", "awsretrycount.totalcount", "awshttpclientpoolavailablecount", "awshttpclientpoolleasedcount", "awshttpclientpoolpendingcount" from "trino.plugin.hive.metastore.glue:name=hive,type=gluehivemetastore"; Result: "awsservicecallduration.alltime.avg","awsservicecallduration.alltime.count","awsapicallduration.alltime.avg","awsapicallduration.alltime.count","awsbackoffdelayduration.alltime.avg","awsbackoffdelayduration.alltime.count","awsthrottleexceptions.totalcount","awsrequestcount.totalcount","awsretrycount.totalcount","awshttpclientpoolavailablecount","awshttpclientpoolleasedcount","awshttpclientpoolpendingcount" "920.0434782608696","23.0","924.3913043478261","23.0","0.0","23.0","0","23","0","1","0","0" ``` Co-authored-by: Karan Makhija<[email protected]>
…client-to-current-region This commit addresses review comments and includes following changes - 1. Uses paginator APIs provided by SDK V2 to avoid handling pagination externally 2. Deprecates "hive.metastore.glue.pin-client-to-current-region" as the SDK will automatically try to determine the region if the code is running in EC2 machine.
4343d86
to
b227e82
Compare
@electrum @findinpath rebased again, could you please check ? |
This pull request has gone a while without any activity. Tagging the Trino developer relations team: @bitsondatadev @colebow @mosabua |
👋 @ShubhamChaurasia @findinpath @electrum .. could you please collaborate and figure out if this PR and approach is still valid and should be implemented. We're working on closing out old and inactive PRs, so if you're too busy or this has too many merge conflicts to be worth picking back up, we'll be making another pass to close it out in a few weeks. |
@ShubhamChaurasia pls rebase. We should be now in good shape to review the changes to eventually land this PR. |
@mosabua @findinpath thanks for letting me know, will give rebase a try. |
This pull request has gone a while without any activity. Tagging the Trino developer relations team: @bitsondatadev @colebow @mosabua |
@ShubhamChaurasia do you still plan to continue with the work needed to land this PR? |
This pull request has gone a while without any activity. Tagging the Trino developer relations team: @bitsondatadev @colebow @mosabua |
Closing this pull request, as it has been stale for six weeks. Feel free to re-open at any time. |
This PR is made redundant by the merged update with much more improvements in #20657 |
Description
This PR updates the glue client to AWS SDK v2. It mainly converts the GlueHiveMetastore and TrinoGlueCatalog used by respectively
trino-hive
andtrino-iceberg
to v2.v1 version
v2 version
In v1 the async client extended the sync client and hence had both the sync and async methods. In v2, the async client only has the async methods which return CompletableFuture. In order to use the async method for a sync call, it needs to be blocked using join() or get(). As this is a common use case the handling has been added as a utility to io.trino.plugin.hive.metastore.glue.AwsSdkUtil.
The request handlers are converted to use the
ExecutionInterceptor
which is used to intercept the request and perform several actions during the lifecycle of the request.Converting MetricsRequester to MetricsPublisher to collect metrics and store them in GlueMetastoreStats. Some of the metrics have been changed. Below is the result.
v1 version
v2 version
Co-authored-by: Karan Makhija[email protected]
Release notes
( ) This is not user-visible or docs only and no release notes are required.
( ) Release notes are required, please propose a release note for me.
(x) Release notes are required, with the following suggested text: