trino: Slow down of presto-cli and presto-jdbc in JDK 11 environment
Problem
When we run the console program or program using presto-jdbc in JDK 11 environment, it is too slow to complete the execution. In JDK 11 environment, the program tries to construct the connection with HTTP 2 instead of HTTP 1.1.
While the coordinator does not support HTTP 2 yet, it can be a problem when we access to the coordinator through proxy or load balancer such as ALB supporting HTTP 2.
This query took several minutes to complete. api-presto.treasuredata.com is an endpoint to the public ALB supporting presto protocol.
$ ./presto-cli-317-SNAPSHOT-executable.jar \
--server https://api-presto.treasuredata.com \
--catalog td-presto \
--user XXXXXXXXXXXXXXXXX \
--execute "select 1234"
This seems to be caused by a non-daemon thread running in OkHttpClient with HTTP 2.0. (ref: https://github.com/square/okhttp/issues/4029).
Workaround
As a workaround, there are two ways to disable HTTP 2 on the client-side.
- Use JDK 8 not to use HTTP 2
- Specify HTTP 1.1 explicitly in the OkHttpClient as follows.
OkHttpClient.Builder builder = new OkHttpClient.Builder();
builder.protocols(Arrays.asList(Protocol.HTTP_1_1));
Both ways work for me.
Discussion
Currently, it is not a huge problem in the usual cases because Presto does not support HTTP 2 yet. But it can prevent Presto from supporting HTTP 2 migration. The issue in OkHttp says that we should close the connection pool properly by okHttpClient.connectionPool().evictAll() but it’s not a solution in the long-running program like presto-cli/presto-jdbc.
How can we support the HTTP 2 environment from presto-cli and presto-jdbc?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 25 (22 by maintainers)
@paulolieuthier We do not have a configuration to disable socket channel or ensure to use HTTP 1.1.
The issue in OkHttp seems to be fixed in 4.3. I’ll try to use the latest version in Presto client. https://github.com/square/okhttp/issues/4029#issuecomment-562874876