Skip to content

Repro for channel hang with pls extensions disabled - #6554

Merged
yschimke merged 6 commits into
lysine-dev:masterfrom
yschimke:socketchannel
Feb 14, 2021
Merged

yschimke merged 6 commits into
lysine-dev:masterfrom
yschimke:socketchannel

Conversation

@yschimke

@yschimke yschimke commented Feb 8, 2021 •

Copy link
Copy Markdown
Collaborator

https://twitter.com/virus_dave/status/1358266888543997952

Failing on JDK 11, with SocketChannel instead of regular socket, unless pls extensions are disabled.

@yschimke

yschimke commented Feb 8, 2021

Copy link
Copy Markdown
Collaborator Author

image

@yschimke

yschimke commented Feb 9, 2021

Copy link
Copy Markdown
Collaborator Author

Looking at the traffic, the app is sending the request, but it's not hitting the network.

READ: TLSv1.2 application_data, length = 42
<< 0x00000000     0 SETTINGS      ACK
Plaintext after DECRYPTION
  0000: 00 00 00 04 01 00 00 00   00                       .........
<< 0x00000000     0 SETTINGS      ACK
>> 0x00000003    40 HEADERS       END_STREAM|END_HEADERS
WRITE: TLS13 application_data, length = 49
Plaintext before ENCRYPTION
  0000: 00 00 28 01 05 00 00 00   03 82 84 41 8B A0 E4 1D  ..(........A....
  0010: 13 9D 09 B8 DB A1 75 AF   87 50 83 9B D9 AB 7A 91  ......u..P....z.
  0020: 3F 59 D2 9A D8 6D 70 2E   05 B7 69 87 5E EC 7A B7  ?Y...mp...i.^.z.
  0030: FF 17 00 00 00 00 00 00   00 00 00 00 00 00 00 00  ................
  0040: 00 00       

image

@yschimke

yschimke commented Feb 9, 2021

Copy link
Copy Markdown
Collaborator Author

Failing on Conscrypt with SocketChannel also
image

@yschimke

yschimke commented Feb 9, 2021

Copy link
Copy Markdown
Collaborator Author

cc @prbprbprb

@swankjesse

Copy link
Copy Markdown
Collaborator

What's the failure mode? Is it just a missing flush?

@yschimke

Copy link
Copy Markdown
Collaborator Author

It gets stuck in a write call

@yschimke

Copy link
Copy Markdown
Collaborator Author

@swankjesse I think the test on it's own has value. Would like to land as is then work on the fix as a separate fix or workaround.

@yschimke

yschimke commented Feb 10, 2021 •

Copy link
Copy Markdown
Collaborator Author

We end up with reader threads blocked in SocketChannelRead with a lock

"OkHttp localhost@4208" daemon prio=5 tid=0x32 nid=NA runnable
  java.lang.Thread.State: RUNNABLE
	 blocks OkHttp https://localhost:61953/...@3648
	  at sun.nio.ch.FileDispatcherImpl.read0(FileDispatcherImpl.java:-1)
	  at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39)
	  at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:276)
	  at sun.nio.ch.IOUtil.read(IOUtil.java:245)
	  at sun.nio.ch.IOUtil.read(IOUtil.java:223)
	  at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:355)
	  at sun.nio.ch.SocketAdaptor$SocketInputStream.read(SocketAdaptor.java:203)
	  - locked <0x1097> (a java.lang.Object)
	  at sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:103)
	  - locked <0x1098> (a sun.nio.ch.SocketAdaptor$SocketInputStream)
	  at sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:478)
	  at sun.security.ssl.SSLSocketInputRecord.readHeader(SSLSocketInputRecord.java:472)
	  at sun.security.ssl.SSLSocketInputRecord.bytesInCompletePacket(SSLSocketInputRecord.java:70)
	  at sun.security.ssl.SSLSocketImpl.readApplicationRecord(SSLSocketImpl.java:1354)
	  at sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:963)
	  at okio.InputStreamSource.read(JvmOkio.kt:93)
	  at okio.AsyncTimeout$source$1.read(AsyncTimeout.kt:125)
	  at okio.RealBufferedSource.request(RealBufferedSource.kt:60)
	  at okio.RealBufferedSource.require(RealBufferedSource.kt:53)
	  at okhttp3.internal.http2.Http2Reader.nextFrame(Http2Reader.kt:89)
	  at okhttp3.internal.http2.Http2Connection$ReaderRunnable.invoke(Http2Connection.kt:618)
	  at okhttp3.internal.http2.Http2Connection$ReaderRunnable.invoke(Http2Connection.kt:609)
	  at okhttp3.internal.concurrent.TaskQueue$execute$1.runOnce(TaskQueue.kt:98)
	  at okhttp3.internal.concurrent.TaskRunner.runTask(TaskRunner.kt:116)
	  at okhttp3.internal.concurrent.TaskRunner.access$runTask(TaskRunner.kt:42)
	  at okhttp3.internal.concurrent.TaskRunner$runnable$1.run(TaskRunner.kt:65)
	  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	  at java.lang.Thread.run(Thread.java:834)

and writers blocked at

"OkHttp https://localhost:61953/...@3648" prio=5 tid=0x2e nid=NA waiting for monitor entry
  java.lang.Thread.State: BLOCKED
	 waiting for OkHttp localhost@4208 to release lock on <0x1097> (a java.lang.Object)
	  at java.nio.channels.Channels.writeFully(Channels.java:92)
	  at java.nio.channels.Channels$1.write(Channels.java:172)
	  - locked <0x1094> (a java.nio.channels.Channels$1)
	  at sun.security.ssl.SSLSocketOutputRecord.deliver(SSLSocketOutputRecord.java:319)
	  - locked <0x1095> (a sun.security.ssl.SSLSocketOutputRecord)
	  at sun.security.ssl.SSLSocketImpl$AppOutputStream.write(SSLSocketImpl.java:1202)
	  at okio.OutputStreamSink.write(JvmOkio.kt:56)
	  at okio.AsyncTimeout$sink$1.write(AsyncTimeout.kt:99)
	  at okio.RealBufferedSink.flush(RealBufferedSink.kt:183)
	  at okhttp3.internal.http2.Http2Writer.flush(Http2Writer.kt:120)
	  - locked <0x1096> (a okhttp3.internal.http2.Http2Writer)
	  at okhttp3.internal.http2.Http2Connection.newStream(Http2Connection.kt:268)
	  at okhttp3.internal.http2.Http2Connection.newStream(Http2Connection.kt:225)
	  at okhttp3.internal.http2.Http2ExchangeCodec.writeRequestHeaders(Http2ExchangeCodec.kt:76)
	  at okhttp3.internal.connection.Exchange.writeRequestHeaders(Exchange.kt:63)
	  at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:41)
	  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	  at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34)
	  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	  at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
	  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	  at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
	  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	  at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
	  at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	  at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
	  at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
	  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	  at java.lang.Thread.run(Thread.java:834)

worse when we timeout they cleanup works gets blocked in a closeQuietly call

"Test worker@1603" prio=5 tid=0xf nid=NA waiting for monitor entry
  java.lang.Thread.State: BLOCKED
	 waiting for OkHttp localhost@4209 to release lock on <0x1139> (a java.lang.Object)
	  at java.nio.channels.Channels.writeFully(Channels.java:92)
	  at java.nio.channels.Channels$1.write(Channels.java:172)
	  - locked <0x1137> (a java.nio.channels.Channels$1)
	  at sun.security.ssl.SSLSocketOutputRecord.encodeAlert(SSLSocketOutputRecord.java:81)
	  - locked <0x1138> (a sun.security.ssl.SSLSocketOutputRecord)
	  at sun.security.ssl.TransportContext.warning(TransportContext.java:247)
	  at sun.security.ssl.SSLSocketImpl.closeNotify(SSLSocketImpl.java:645)
	  at sun.security.ssl.SSLSocketImpl.duplexCloseOutput(SSLSocketImpl.java:631)
	  at sun.security.ssl.SSLSocketImpl.close(SSLSocketImpl.java:566)
	  at okhttp3.internal.Util.closeQuietly(Util.kt:507)
	  at okhttp3.internal.connection.RealConnectionPool.evictAll(RealConnectionPool.kt:132)
	  at okhttp3.ConnectionPool.evictAll(ConnectionPool.kt:57)
	  at okhttp3.OkHttpClientTestRule.ensureAllConnectionsReleased(OkHttpClientTestRule.kt:148)
	  at okhttp3.OkHttpClientTestRule.afterEach(OkHttpClientTestRule.kt:212)

@yschimke

Copy link
Copy Markdown
Collaborator Author

@swankjesse I think the test on it's own has value. Would like to land as is then work on the fix as a separate fix or workaround.

Going to land this as it's test only, would appreciate a follow up approval, or I can revert. But I'm stacking GitHub PRs at this point.

@yschimke
yschimke merged commit 6901b9c into lysine-dev:master Feb 14, 2021

@swankjesse swankjesse left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sorry for the slow review. Is there anything we'll fix from this?

@yschimke

Copy link
Copy Markdown
Collaborator Author

LGTM

We could probably try to make channels work slowly by avoid long blocking operations, but I just told presto to avoid.

@yschimke
yschimke deleted the socketchannel branch April 16, 2021 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants