-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Add support for HTTP transport in thrift metastore client #20371
Add support for HTTP transport in thrift metastore client #20371
Conversation
What's the difference from #17925? |
This PR attempts the recommendation from @findinpath to try to completely separate the code path for thrift metastore client and http metastore client to avoid the concern raised by you about having to validate configs like impersonation which do not work with http metastore client in HivePlugin. This is done by creating a http client factory instead of overloading the Default thrift based client factory. I feel this could be a cleaner approach but would love to understand your opinion on this approach before spending more time and taking this further. Let me know if you think this is better approach than #17925. If yes, I can discard this PR and update the original one with these changes. |
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.
...ve/src/main/java/io/trino/plugin/hive/metastore/thrift/HttpThriftMetastoreClientFactory.java
Outdated
Show resolved
Hide resolved
...in/trino-hive/src/main/java/io/trino/plugin/hive/metastore/thrift/ThriftMetastoreModule.java
Outdated
Show resolved
Hide resolved
plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHivePlugin.java
Outdated
Show resolved
Hide resolved
...rino-hive/src/main/java/io/trino/plugin/hive/metastore/thrift/ThriftHttpMetastoreConfig.java
Outdated
Show resolved
Hide resolved
...in/trino-hive/src/main/java/io/trino/plugin/hive/metastore/thrift/ThriftMetastoreModule.java
Outdated
Show resolved
Hide resolved
I am happy to address these comments but with all due respect I would like to hear from @ebyhr if this is the approach which is strictly better and would make this PR worthy to be merged eventually. Unfortunately, this work has taken more than 6 months of back and forth (including holidays) and I would like to make sure that any time and energy that I spent on this is eventually going to take this PR towards getting it merged from @ebyhr or anyone else who can help merge the PR. Also, should we abandon this PR and update the original PR or do you want me to use this PR from now? |
@vihangk1 This approach looks better than the previous one. Please feel free to close the old 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.
Only nits
The only question is whether the following binding in the ThriftMetastoreModule
when dealing with a http/https metastore is actually justified:
configBinder(binder).bindConfig(ThriftMetastoreConfig.class);
I hope not.
...src/main/java/io/trino/plugin/hive/metastore/thrift/DefaultThriftMetastoreClientFactory.java
Outdated
Show resolved
Hide resolved
...in/trino-hive/src/main/java/io/trino/plugin/hive/metastore/thrift/ThriftMetastoreModule.java
Outdated
Show resolved
Hide resolved
...s/docker/presto-product-tests/conf/environment/multinode-databricks-http-hms/hive.properties
Outdated
Show resolved
Hide resolved
.../docker/presto-product-tests/conf/environment/multinode-databricks-http-hms/delta.properties
Outdated
Show resolved
Hide resolved
...-product-tests/src/main/java/io/trino/tests/product/hive/TestHiveMetastoreClientFactory.java
Outdated
Show resolved
Hide resolved
...main/java/io/trino/tests/product/launcher/env/environment/EnvMultinodeDatabricksHttpHms.java
Outdated
Show resolved
Hide resolved
...main/java/io/trino/tests/product/launcher/env/environment/EnvMultinodeDatabricksHttpHms.java
Outdated
Show resolved
Hide resolved
...in/trino-hive/src/main/java/io/trino/plugin/hive/metastore/thrift/ThriftMetastoreModule.java
Outdated
Show resolved
Hide resolved
plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestingThriftHiveMetastoreBuilder.java
Outdated
Show resolved
Hide resolved
...ve/src/main/java/io/trino/plugin/hive/metastore/thrift/HttpThriftMetastoreClientFactory.java
Outdated
Show resolved
Hide resolved
@vihangk1 pls also rebase on |
If I comment out ThriftMetastoreConfig binding, I get the following error when I run TestHivePlugin [ERROR] Errors:
|
@vihangk1 here is a patch to solve the binding problem which was keeping you from removing the dependency towards
|
e623f6d
to
74b63f6
Compare
Build is 🔴
|
0e5df58
to
8e52e2e
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.
LGTM % comments
...ino-hive/src/main/java/io/trino/plugin/hive/metastore/thrift/ThriftHttpMetastoreFactory.java
Outdated
Show resolved
Hide resolved
...-hive/src/test/java/io/trino/plugin/hive/metastore/thrift/TestThriftHttpMetastoreClient.java
Outdated
Show resolved
Hide resolved
8e52e2e
to
6dab693
Compare
plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestingThriftHiveMetastoreBuilder.java
Outdated
Show resolved
Hide resolved
plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestingThriftHiveMetastoreBuilder.java
Outdated
Show resolved
Hide resolved
...-hive/src/test/java/io/trino/plugin/hive/metastore/thrift/TestHttpThriftMetastoreConfig.java
Outdated
Show resolved
Hide resolved
...-hive/src/test/java/io/trino/plugin/hive/metastore/thrift/TestHttpThriftMetastoreConfig.java
Outdated
Show resolved
Hide resolved
...rino-hive/src/main/java/io/trino/plugin/hive/metastore/thrift/ThriftHttpMetastoreConfig.java
Outdated
Show resolved
Hide resolved
...-hive/src/test/java/io/trino/plugin/hive/metastore/thrift/TestThriftHttpMetastoreClient.java
Outdated
Show resolved
Hide resolved
...-hive/src/test/java/io/trino/plugin/hive/metastore/thrift/TestThriftHttpMetastoreClient.java
Outdated
Show resolved
Hide resolved
...main/java/io/trino/tests/product/launcher/env/environment/EnvMultinodeDatabricksHttpHms.java
Outdated
Show resolved
Hide resolved
...main/java/io/trino/tests/product/launcher/env/environment/EnvMultinodeDatabricksHttpHms.java
Outdated
Show resolved
Hide resolved
...main/java/io/trino/tests/product/launcher/env/environment/EnvMultinodeDatabricksHttpHms.java
Outdated
Show resolved
Hide resolved
Could you confirm product test failure? https://github.com/trinodb/trino/actions/runs/7881376966/job/21505082153?pr=20371 |
This is related to an internal hickup in the Databricks account used for testing Trino OSS. Apparently someone removed (accidentaly) in the meantime the Unity cluster. Recreating the cluster. |
|
27758b7
to
2b5f643
Compare
...src/main/java/io/trino/plugin/hive/metastore/thrift/DefaultThriftMetastoreClientFactory.java
Outdated
Show resolved
Hide resolved
...ve/src/main/java/io/trino/plugin/hive/metastore/thrift/HttpThriftMetastoreClientFactory.java
Outdated
Show resolved
Hide resolved
...ve/src/main/java/io/trino/plugin/hive/metastore/thrift/HttpThriftMetastoreClientFactory.java
Outdated
Show resolved
Hide resolved
...ve/src/main/java/io/trino/plugin/hive/metastore/thrift/HttpThriftMetastoreClientFactory.java
Outdated
Show resolved
Hide resolved
...-hive/src/test/java/io/trino/plugin/hive/metastore/thrift/TestThriftHttpMetastoreClient.java
Outdated
Show resolved
Hide resolved
plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHivePlugin.java
Outdated
Show resolved
Hide resolved
...in/trino-hive/src/main/java/io/trino/plugin/hive/metastore/thrift/ThriftMetastoreModule.java
Outdated
Show resolved
Hide resolved
...ino-hive/src/main/java/io/trino/plugin/hive/metastore/thrift/ThriftHttpMetastoreFactory.java
Show resolved
Hide resolved
...rino-hive/src/main/java/io/trino/plugin/hive/metastore/thrift/ThriftHiveMetastoreClient.java
Outdated
Show resolved
Hide resolved
...n/java/io/trino/plugin/hive/metastore/thrift/StaticTokenAwareHttpMetastoreClientFactory.java
Outdated
Show resolved
Hide resolved
1762171
to
20cd909
Compare
@@ -144,9 +143,9 @@ private static URI checkMetastoreUri(URI uri) | |||
requireNonNull(uri, "uri is null"); | |||
String scheme = uri.getScheme(); | |||
checkArgument(!isNullOrEmpty(scheme), "metastoreUri scheme is missing: %s", uri); | |||
checkArgument(scheme.equals("thrift"), "metastoreUri scheme must be thrift: %s", uri); | |||
checkArgument(scheme.equals("thrift") || scheme.equals("https") || scheme.equals("http"), "metastoreUri scheme must be thrift, http or https: %s", uri); |
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.
Removing this check for https and http because this class only works with thrift now.
BEARER | ||
} | ||
|
||
private Duration readTimeout = new Duration(10, TimeUnit.SECONDS); |
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.
Updating this to 60 seconds which is the timeout value for Databricks.
...src/main/java/io/trino/plugin/hive/metastore/thrift/DefaultThriftMetastoreClientFactory.java
Outdated
Show resolved
Hide resolved
...ve/src/main/java/io/trino/plugin/hive/metastore/thrift/HttpThriftMetastoreClientFactory.java
Outdated
Show resolved
Hide resolved
...ve/src/main/java/io/trino/plugin/hive/metastore/thrift/HttpThriftMetastoreClientFactory.java
Outdated
Show resolved
Hide resolved
...ve/src/main/java/io/trino/plugin/hive/metastore/thrift/HttpThriftMetastoreClientFactory.java
Outdated
Show resolved
Hide resolved
...ve/src/main/java/io/trino/plugin/hive/metastore/thrift/HttpThriftMetastoreClientFactory.java
Outdated
Show resolved
Hide resolved
...ino-hive/src/main/java/io/trino/plugin/hive/metastore/thrift/ThriftHttpMetastoreFactory.java
Outdated
Show resolved
Hide resolved
...rc/main/java/io/trino/tests/product/deltalake/TestDeltaLakeDatabricksUnityCompatibility.java
Outdated
Show resolved
Hide resolved
...rc/main/java/io/trino/tests/product/deltalake/TestDeltaLakeDatabricksUnityCompatibility.java
Outdated
Show resolved
Hide resolved
...rc/main/java/io/trino/tests/product/deltalake/TestDeltaLakeDatabricksUnityCompatibility.java
Outdated
Show resolved
Hide resolved
...rc/main/java/io/trino/tests/product/deltalake/TestDeltaLakeDatabricksUnityCompatibility.java
Outdated
Show resolved
Hide resolved
It is a game changer for us! Thank you for contributing this feature |
Regarding token expiration. How will Trino handle the refreshing of the token or fetching a new token if needed? |
...rc/main/java/io/trino/tests/product/deltalake/TestDeltaLakeDatabricksUnityCompatibility.java
Outdated
Show resolved
Hide resolved
20cd909
to
db1c627
Compare
db1c627
to
9241b75
Compare
9241b75
to
d7cb320
Compare
Semi related question.. are there good reasons why this is not using the airlift http client and its configuration like other http client use cases in Trino - see https://trino.io/docs/current/admin/properties-http-client.html cc @colebow |
Description
This PR adds support for using HTTP as the transport for the thrift metastore client. In this mode the hive.metastore.uri can support a http(s) URL to the metastore service. Since each thrift API is a POST request to the the metastore endpoint, this PR also adds support for adding a HTTP bearer token which must be configured to authenticate the metastore client to the metastore server. The token can be configured using a configuration hive.metastore.http.client.bearer-token. To support Databricks Unity Catalog's HMS API interface, the configuration hive.metastore.http.client.additional-headers must be set to X-Databricks-Unity-Catalog-Name=<catalog_name> where the catalog_name is the name of the catalog object in Databricks Unity Catalog.
Additional context and related issues
Thrift has support HTTP based transport for a long time. Ref https://github.com/apache/thrift/blob/master/lib/javame/src/org/apache/thrift/transport/THttpClient.java. We have used the http mode for thrift on various services in other projects like HiveServer2 in Apache Hive and Apache Spark for a while now.
More recently, Apache Hive also added support for Hive Metastore server to use HTTP mode.
https://issues.apache.org/jira/browse/HIVE-21456
This PR modifies the logic in HttpThriftMetastoreClientFactory to instantiate THttpClient for the transport when creating the thrift metastore client.
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:
Add HTTP support for the thrift metastore client.