JDK-8249590 : Timeout not correctly reported as SocketTimeoutException but as SocketException
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 8u181
  • Priority: P4
  • Status: Closed
  • Resolution: Incomplete
  • OS: windows_2012
  • CPU: x86
  • Submitted: 2020-07-09
  • Updated: 2021-08-31
  • Resolved: 2021-08-31
Related Reports
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
Windows Server 2016, JDK 8u151

A DESCRIPTION OF THE PROBLEM :
*Please note, that this bug was observed on Windows Server 2016, not 2012 R2, but that platform is not selectable on the report sheet.*

Under heavy load situations on Windows Server 2016 and JDK8 we are seeing socket timeout events, that are not correctly reported to the application as SocketTimeoutExceptions, but as SocketExceptions with a message of "recv failed". (Probably related: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8152654):

    java.net.SocketException: Unrecognized Windows Sockets error: 0: recv failed

We believe, this is a race condition in fetching the WINSOCK error code in SocketInputStream.c - the error code is fetched too late and has changed/been reset in the mean time. We tried openJDK 8, which showed the same behviour. We tried to acquired the error code earlier in openJDK 8 and were successfully in preventing this error.

Please note, that a patch to the same end has been applied to openJDK 12, see [1], third patch segment.

[1]: https://hg.openjdk.java.net/jdk/jdk12/rev/9aa7ac61e68c

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Open multiple/hundreds threads with socket read timeouts, send data to and fro. Some sockets should be used in a highly asymmetrical fashion: only data is sent, but none read, thus read timeouts are trigger.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
All read timeouts are reported as SocketTimeoutExceptions.
ACTUAL -
Some timeouts are reported as SocketExceptions, with message "recv failed".

FREQUENCY : occasionally
Comments
Did not receive any response from the submitter. Closed as incomplete.
31-08-2021

Requested the submitter to verify the fix by downloading the latest version of JDK 18 from https://jdk.java.net/18/
19-08-2021

[~tongwan] Can you follow up with the submitter to see if this issue can be closed?
18-08-2021

May be a dup of JDK-8210147, fixed in newer updates.
23-07-2020

Possibly related to https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8152654. A patch has been applied to openJDK 12, see [1], third patch segment. [1]: https://hg.openjdk.java.net/jdk/jdk12/rev/9aa7ac61e68c
16-07-2020

Possible race condition while reading WINSOCK error code in JDK8. Instead of getting SocketTimeoutException SocketExceptions with a message of "recv failed" is received. Submitter faced issue on Windows Server 2016 and not 2012 R2.
16-07-2020