RFR: 8291652: (ch) java/nio/channels/SocketChannel/VectorIO.java failed with "Exception: Server 15: Timed out"
Mark Sheppard
msheppar at openjdk.org
Thu Sep 11 11:38:33 UTC 2025
On Mon, 30 Jun 2025 15:58:16 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:
> Can I please get a review of this test-only change which proposes to address an intermittent test failure in `java/nio/channels/SocketChannel/VectorIO.java`?
>
> As noted in https://bugs.openjdk.org/browse/JDK-8291652, this test has been failing intermittently in our CI. Some years back the test was improved to include additional debug logs to identify the root cause https://bugs.openjdk.org/browse/JDK-8180085. In a recent failure, these test logs indicate that the `Server` thread hadn't yet `accept()`ed a Socket connection, when the client side of the test threw an exception because it had waited for 8 seconds for the server side of the test to complete.
>
> The change in this PR updates the test to wait for the `Server` thread to reach a point where it is ready to `accept()` a Socket connection. Only after it reaches this state, the client side of the testing will be initiated. Furthermore, the artificial 8 second wait has been removed from this test and it now waits as long as it takes for the testing to complete. If the test waits far too long then the jtreg infrastructure will timeout the test and at the same time capture the necessary artifacts to help debug unexpected time outs.
>
> While at it, the test has also been updated to use `InetAddress.getLoopbackAddress()` instead of localhost. This should prevent any unexpected address mappings for localhost from playing a role in this test.
>
> With these changes, I've run the test more than 1000 times in our CI and it hasn't failed.
test/jdk/java/nio/channels/SocketChannel/VectorIO.java line 135:
> 133: this.testSize = testSize;
> 134: InetAddress loopback = InetAddress.getLoopbackAddress();
> 135: this.ssc = ServerSocketChannel.open().bind(new InetSocketAddress(loopback, 0));
I think it's better to use the two arg version of bind and specify a backlog e.g. 5 to provide consistent behaviour across all OS platforms c.f. Stevens Unix network programming 3rd edition page 106 for recommendation against backlog 0
test/jdk/java/nio/channels/SocketChannel/VectorIO.java line 149:
> 147: // await for the server to be ready to accept the
> 148: // connections from the client/test
> 149: private void waitToStartTest() throws InterruptedException {
refactor rename waitServerStart
test/jdk/java/nio/channels/SocketChannel/VectorIO.java line 174:
> 172:
> 173: ssc.configureBlocking(false);
> 174: connAcceptLatch.countDown();
refactor extract method signalServerStart for symmetry with waitServerStart
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26049#discussion_r2340332952
PR Review Comment: https://git.openjdk.org/jdk/pull/26049#discussion_r2340340518
PR Review Comment: https://git.openjdk.org/jdk/pull/26049#discussion_r2340345892
More information about the nio-dev
mailing list