badaiaqrandista commented on code in PR #12416: URL: https://github.com/apache/kafka/pull/12416#discussion_r929317899
########## core/src/test/scala/unit/kafka/network/SocketServerTest.scala: ########## @@ -1878,6 +1878,93 @@ class SocketServerTest { }, false) } + /** + * Tests for KAFKA-13559 - Processing request got delayed by 300 ms in the following condition: + * 1. Client-Server communication uses SSL socket. + * 2. More than one requests are read from the socket into SslTransportLayer.netReadBuffer. + * + * This 300 ms delay occurs because the socket has no data but the buffer has data. And the sequence of events that + * leads to this situation is the following (from the server point of view): + * + * Step 1 - SslTransportLayer receives more than one requests in the socket and put it in the buffer + * (SslTransportLayer.netReadBuffer). + * Step 2 - SslTransportLayer reads all of the bytes and stores it in SslTransportLayer.appReadBuffer. + * Step 3 - Process the first request, leaving the second request in SslTransportLayer.appReadBuffer. + * Step 4 - THIS IS WHERE THE DELAY IS. Process the second request. This request is read from + * SslTransportLayer.appReadBuffer, instead of the socket. Because of this, "select(timeout)" in "Selector.poll()" + * should not block for the "poll timeout" (hardcoded to 300 in Selector.java, but in this test it is set to 5000). + * + * This test is implemented following "makeSocketWithBufferedRequests()" method by putting two requests directly + * into SslTransportLayer.netReadBuffer and manually trigger the processing. + * + */ + @Test + def testLatencyWithBufferedDataAndNoSocketData(): Unit = { + shutdownServerAndMetrics(server) + + // create server with SSL listener Review Comment: done ########## core/src/test/scala/unit/kafka/network/SocketServerTest.scala: ########## @@ -1878,6 +1878,93 @@ class SocketServerTest { }, false) } + /** + * Tests for KAFKA-13559 - Processing request got delayed by 300 ms in the following condition: + * 1. Client-Server communication uses SSL socket. + * 2. More than one requests are read from the socket into SslTransportLayer.netReadBuffer. + * + * This 300 ms delay occurs because the socket has no data but the buffer has data. And the sequence of events that + * leads to this situation is the following (from the server point of view): + * + * Step 1 - SslTransportLayer receives more than one requests in the socket and put it in the buffer + * (SslTransportLayer.netReadBuffer). + * Step 2 - SslTransportLayer reads all of the bytes and stores it in SslTransportLayer.appReadBuffer. + * Step 3 - Process the first request, leaving the second request in SslTransportLayer.appReadBuffer. + * Step 4 - THIS IS WHERE THE DELAY IS. Process the second request. This request is read from + * SslTransportLayer.appReadBuffer, instead of the socket. Because of this, "select(timeout)" in "Selector.poll()" + * should not block for the "poll timeout" (hardcoded to 300 in Selector.java, but in this test it is set to 5000). + * + * This test is implemented following "makeSocketWithBufferedRequests()" method by putting two requests directly + * into SslTransportLayer.netReadBuffer and manually trigger the processing. + * + */ + @Test + def testLatencyWithBufferedDataAndNoSocketData(): Unit = { + shutdownServerAndMetrics(server) + + // create server with SSL listener + val testableServer = new TestableSocketServer(KafkaConfig.fromProps(sslServerProps)) + testableServer.enableRequestProcessing(Map.empty) + val testableSelector = testableServer.testableSelector + val proxyServer = new ProxyServer(testableServer) + val selectTimeout = 5000 // in ms Review Comment: done -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org