8383768: java/net/Socket/SocketReadInterruptTest.java failed with SocketTimeoutException: Read timed out - #32051
Open
jaikiran wants to merge 1 commit into
Open
8383768: java/net/Socket/SocketReadInterruptTest.java failed with SocketTimeoutException: Read timed out#32051jaikiran wants to merge 1 commit into
jaikiran wants to merge 1 commit into
Conversation
…ketTimeoutException: Read timed out
|
👋 Welcome back jpai! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Can I please get a review of this test-only fix to the
test/jdk/java/net/Socket/SocketReadInterruptTest.javatest that fails intermittently? This addresses https://bugs.openjdk.org/browse/JDK-8383768.The test was introduced back in JDK 16 when addressing https://bugs.openjdk.org/browse/JDK-8237858. The (old)
PlainSocketImplbasedjava.net.Socketimplementation at that time had a bug where if "ServerSocket.accept()" was blocked waiting for a connection and if the nativeaccept()call returnedEINTRdue to that system call being terminated by a signal, then the Java application would end up incorrectly receiving ajava.net.SocketTimeoutException: Accept timed outexception. That issued was fixed in JDK 16 and a couple of new jtreg tests were introduced to verify the fix. ThisSocketReadInterruptTestwas one of those. Details of that fix and the test introduction are available in the RFR email at that time:https://mail.openjdk.org/pipermail/net-dev/2020-March/013637.html
and
https://mail.openjdk.org/pipermail/net-dev/2020-March/013646.html
The old
PlainSocketImplimplementation ofjava.net.Socketis no longer present in the JDK mainline. However, I think the idea is still a valid one to verify that the Java application doesn't receive an unexpected exception when it is blocked onServerSocket.accept()orSocket.read()and theaccept()orread()system calls returned withEINTR. So theSocketReadInterruptTest(and theSocketAcceptInterruptTest), I think are still good to have in the JDK mainline.The
SocketReadInterruptTesthas been failing intermittently. What the test does is, it creates aServerSocket, thenaccept()s the connection from the test'sSocket. The test then initiates aSocket.read()with a socket read timeout of 3 seconds. On the server side, theServerSocketafter accepting the connection will wait for 2 seconds before writing out a response on the accepted socket's outputstream.When the client side is waiting in
Socket.read()(for a duration of 3 seconds), the test sends out a signal to the native thread which is blocked on theread()system call. This it does so that theread()system call returns with aEINTR. The test then expects that no exception propagates to theSocket.read()call and instead theSocket.read()completes normally. This works fine in most cases.However, on certain occasions, if the server thread which is responsible for writing out the response, is delayed for longer than the 3 second client read duration, and as a result cannot write out the response, then the client side
Socket.read()ends up with aSocketTimeoutException: Read timed outas seen in these intermittent failures.The fix in this PR addresses the test issue by changing the socket read timeout from 3 seconds to a very large timeout. This will allow the test to exercise the timed read of the
java.net.Socketimplementation and at the same time it should give enough time for the server side to be able to write out the response. Additional changes have been done to make the test more robust as well as easier to understand and maintain.With these changes the test has been run in our CI with a test-repeat of 50 and has also in tier2. No failures have been noticed with this change.
Note that it's likely that the other test
SocketAcceptInterruptTestmight need a general clean up too, but I decided not to do it for now.Progress
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/32051/head:pull/32051$ git checkout pull/32051Update a local copy of the PR:
$ git checkout pull/32051$ git pull https://git.openjdk.org/jdk.git pull/32051/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 32051View PR using the GUI difftool:
$ git pr show -t 32051Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/32051.diff
Using Webrev
Link to Webrev Comment