Skip to content

Force using HTTP1.1 on Java 11 or later to avoid thread hanging on driver#20239

Closed
mblanco-denodo wants to merge 1 commit intoprestodb:masterfrom
mblanco-denodo:issue_okhttp2
Closed

Force using HTTP1.1 on Java 11 or later to avoid thread hanging on driver#20239
mblanco-denodo wants to merge 1 commit intoprestodb:masterfrom
mblanco-denodo:issue_okhttp2

Conversation

@mblanco-denodo
Copy link
Contributor

We have experienced deadlocks on the presto jdbc driver when executing presto with java 11 (by default in java 11, HTTP2 is used). We found that forcing to use HTTP 1.1 solves the problem. A similar issue was also reported on Trino: trinodb/trino#1169
Solution to this problem was added by forcing to use HTTP1.1 if the driver is running on java 11. The same change was made to the cli tool too.

Access(23521)-3817-04.00-testdb.presto_ds" Id=57104 in BLOCKED CpuTime=75496124 on lock=java.lang.Object@492135c1 
     owned by OkHttp localhost Id=57127 
    at java.base@11.0.8/java.nio.channels.Channels.writeFully(Channels.java:91) 
    at java.base@11.0.8/java.nio.channels.Channels$1.write(Channels.java:172) 
    at java.base@11.0.8/sun.security.ssl.SSLSocketOutputRecord.deliver(SSLSocketOutputRecord.java:319) 
    at java.base@11.0.8/sun.security.ssl.SSLSocketImpl$AppOutputStream.write(SSLSocketImpl.java:1197) 
    at com.facebook.presto.jdbc.internal.okio.Okio$1.write(Okio.java:79) 
    at com.facebook.presto.jdbc.internal.okio.AsyncTimeout$1.write(AsyncTimeout.java:180) 
    at com.facebook.presto.jdbc.internal.okio.RealBufferedSink.flush(RealBufferedSink.java:216) 
    at com.facebook.presto.jdbc.internal.okhttp3.internal.http2.Http2Writer.flush(Http2Writer.java:121) 
    at com.facebook.presto.jdbc.internal.okhttp3.internal.http2.Http2Connection.newStream(Http2Connection.java:239) 
    at com.facebook.presto.jdbc.internal.okhttp3.internal.http2.Http2Connection.newStream(Http2Connection.java:205) 
    at com.facebook.presto.jdbc.internal.okhttp3.internal.http2.Http2Codec.writeRequestHeaders(Http2Codec.java:111) 
    at com.facebook.presto.jdbc.internal.okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:50) 
    at com.facebook.presto.jdbc.internal.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 
    at com.facebook.presto.jdbc.internal.okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45) 
    at com.facebook.presto.jdbc.internal.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 
    at com.facebook.presto.jdbc.internal.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) 
    at com.facebook.presto.jdbc.internal.okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93) 
    at com.facebook.presto.jdbc.internal.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 
    at com.facebook.presto.jdbc.internal.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) 
    at com.facebook.presto.jdbc.internal.okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93) 
    at com.facebook.presto.jdbc.internal.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 
    at com.facebook.presto.jdbc.internal.okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:125) 
    at com.facebook.presto.jdbc.internal.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 
    at com.facebook.presto.jdbc.internal.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) 
    at com.facebook.presto.jdbc.internal.client.OkHttpUtil.lambda$basicAuth$1(OkHttpUtil.java:91) 
    at com.facebook.presto.jdbc.internal.client.OkHttpUtil$$Lambda$450/0x0000000800efec40.intercept(Unknown Source) 
    at com.facebook.presto.jdbc.internal.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 
    at com.facebook.presto.jdbc.internal.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) 
    at com.facebook.presto.jdbc.internal.client.OkHttpUtil.lambda$userAgent$0(OkHttpUtil.java:77) 
    at com.facebook.presto.jdbc.internal.client.OkHttpUtil$$Lambda$424/0x0000000800ecd840.intercept(Unknown Source) 
    at com.facebook.presto.jdbc.internal.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 
    at com.facebook.presto.jdbc.internal.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) 
    at com.facebook.presto.jdbc.internal.okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200) 
    at com.facebook.presto.jdbc.internal.okhttp3.RealCall.execute(RealCall.java:77) 
    at com.facebook.presto.jdbc.internal.client.JsonResponse.execute(JsonResponse.java:131) 
    at com.facebook.presto.jdbc.internal.client.StatementClientV1.advance(StatementClientV1.java:389) 
    at com.facebook.presto.jdbc.PrestoResultSet$ResultsPageIterator.computeNext(PrestoResultSet.java:1803) 
    at com.facebook.presto.jdbc.PrestoResultSet$ResultsPageIterator.computeNext(PrestoResultSet.java:1759) 
    at com.facebook.presto.jdbc.internal.guava.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:141) 
    at com.facebook.presto.jdbc.internal.guava.collect.AbstractIterator.hasNext(AbstractIterator.java:136) 
    at com.facebook.presto.jdbc.internal.guava.collect.TransformedIterator.hasNext(TransformedIterator.java:42) 
    at com.facebook.presto.jdbc.internal.guava.collect.Iterators$ConcatenatedIterator.getTopMetaIterator(Iterators.java:1319) 
    at com.facebook.presto.jdbc.internal.guava.collect.Iterators$ConcatenatedIterator.hasNext(Iterators.java:1335) 
    at com.facebook.presto.jdbc.PrestoResultSet.next(PrestoResultSet.java:144) 
    at org.apache.commons.dbcp2.DelegatingResultSet.next(DelegatingResultSet.java:1160) 

Test plan - unit tests in the modified modules

== RELEASE NOTES ==

General Changes

  • Forced to use HTTP 1.1 on presto-jdbc socketFactory when the java runtime version is greater than Java 11
  • Forced to use HTTP 1.1 on presto-cli socketFactory when the java runtime version is greater than Java 11

If release note is NOT required, use:

== NO RELEASE NOTE ==

@mblanco-denodo mblanco-denodo requested a review from a team as a code owner July 7, 2023 10:06
@mblanco-denodo mblanco-denodo requested a review from presto-oss July 7, 2023 10:06
@tdcmeehan
Copy link
Contributor

Should we try to just remove SocketChannelSocketFactory? I see that's what Trino ultimately did and I think that would work here as well.

@mblanco-denodo
Copy link
Contributor Author

Closing PR as other approach was merged in #20262

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants