IV19713: java.nio.channels.Selector.select(long) in tight loop with zero selected keys in Linux
Closed as program error.
Error Message: N/A . Stack Trace: N/A . The application observe a tight loop in the select() method of Selector class which continues till the channels are explicitly cancelled by the application.
Monitor for select() method of Selector class returns with zero selected keys and cancel the channels through application if it exceeds the expected limit.
The root cause of the issue is that there is a very small timing window between a channel set to close (not open) in the Java layer and the actual close of the channel in the native layer. Hence, if the interestOps is set to 0 for that channel by the application during this timing window, the selector presumes that the channel is already closed and do not try to delete the channel from the select operation. Hence, it will result in a situation that on Java side, the interest ops is not selected whereas on the native side the previous interested operation is still selected. If the interested operation is ready on the native side for that channel, then the polling for that channel immediately returns. As the selected operation is no more interested in the Java layer, the application invoke the select() again without clearing the data from the channel. In the meantime, the other thread which tries to close the channel is waiting for the selector lock to cancel the key. As the select() operation immediately returns from the native side polling results in a tight loop, the selector lock is not released. Hence, the channel is not able to close which result in an infinite loop in select() method.
This defect will be fixed in: 6.0.0 SR11 6.0.1 SR3 7.0.0 SR2 . The JVM is updated to ensure that the channels are deleted from the select operation when interestOps is set to zero irrespective of whether the channel is in close processing or not.
Reported component name
JAVA CLASS LIBS
Reported component ID
Last modified date
APAR is sysrouted FROM one or more of the following:
APAR is sysrouted TO one or more of the following:
Fixed component name
JAVA CLASS LIBS
Fixed component ID
Applicable component levels
Translate this page: