[ 
https://issues.apache.org/jira/browse/CALCITE-6209?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17809469#comment-17809469
 ] 

Istvan Toth commented on CALCITE-6209:
--------------------------------------

Also confirming that the problem is not related to CALCITE-5581, I can repro 
the issue on 1.23.
(This is in line with [~konstantinx64]'s anaysis.)

httpclient has the following timeout parameters:

[setConnectTimeout|https://hc.apache.org/httpcomponents-client-5.2.x/current/httpclient5/apidocs/org/apache/hc/client5/http/config/RequestConfig.Builder.html#setConnectTimeout-long-java.util.concurrent.TimeUnit-]
This is connection timeout, as discussed above, and is not relevant here.

[setResponseTimeout|https://hc.apache.org/httpcomponents-client-5.2.x/current/httpclient5/apidocs/org/apache/hc/client5/http/config/RequestConfig.Builder.html#setResponseTimeout-long-java.util.concurrent.TimeUnit-]
This is at play here.
The java.net.SocketTimeoutException is thrown after this time has elapsed.

[setConnectionRequestTimeout|https://hc.apache.org/httpcomponents-client-5.2.x/current/httpclient5/apidocs/org/apache/hc/client5/http/config/RequestConfig.Builder.html#setConnectionRequestTimeout-long-java.util.concurrent.TimeUnit-]
I'm not sure what it does, it possibly comes into play when the httpclient 
connection pool is full.
This does not have an effect on the java.net.SocketTimeoutException.

The simplest way to fix this is to expose the responseTimeout prameter in the 
JDBC URL.

We could generate periodic null reponse segments on the server, or send kind of 
ping packets from the client, but
that would be a much bigger task (and I am not familar enough with the HTTP 
internals to tell if that would even generate traffic on the same TCP socket )

The JDBC Statement.setQueryTimeout() is somewhat related, but it's unlimited by 
default, and I wouldn't tie that to the tcp timeout.




> Long queries are failing with "java.net.SocketTimeoutException: Read timed 
> out" after 3 minutes
> -----------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-6209
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6209
>             Project: Calcite
>          Issue Type: Bug
>          Components: avatica
>    Affects Versions: avatica-1.24.0
>            Reporter: Konstantin
>            Assignee: Istvan Toth
>            Priority: Critical
>         Attachments: screenshot-1.png
>
>
> Long queries are failing with "java.net.SocketTimeoutException: Read timed 
> out" after 3 minutes.
> It's expected that they take more than 3 minutes and we need some way to 
> increase timeout.
> I tried to change it via +http_connection_timeout+ property but it didn't 
> help.
> Looks like that property is related to connect timeout only, but not to 
> request timeout.
> I checked source code but didn't found any ways to change it there.
> Looks like it's always using default timeout=3minutes.
>  !screenshot-1.png! 
> Stack-trace:
> {code:java}
> org.jkiss.dbeaver.model.sql.DBSQLException: SQL Error: Error while executing 
> SQL "SELECT count(1) FROM trace": java.net.SocketTimeoutException: Read timed 
> out
>       at 
> org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.executeStatement(JDBCStatementImpl.java:133)
>       at 
> org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.executeStatement(SQLQueryJob.java:600)
>       at 
> org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.lambda$2(SQLQueryJob.java:503)
>       at 
> org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:190)
>       at 
> org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.executeSingleQuery(SQLQueryJob.java:510)
>       at 
> org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.extractData(SQLQueryJob.java:962)
>       at 
> org.jkiss.dbeaver.ui.editors.sql.SQLEditor$QueryResultsContainer.readData(SQLEditor.java:4130)
>       at 
> org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.lambda$0(ResultSetJobDataRead.java:123)
>       at 
> org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:190)
>       at 
> org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.run(ResultSetJobDataRead.java:121)
>       at 
> org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer$ResultSetDataPumpJob.run(ResultSetViewer.java:5148)
>       at org.jkiss.dbeaver.model.runtime.AbstractJob.run(AbstractJob.java:105)
>       at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
> Caused by: java.sql.SQLException: Error while executing SQL "SELECT count(1) 
> FROM trace": java.net.SocketTimeoutException: Read timed out
>       at org.apache.calcite.avatica.Helper.createException(Helper.java:56)
>       at org.apache.calcite.avatica.Helper.createException(Helper.java:41)
>       at 
> org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:164)
>       at 
> org.apache.calcite.avatica.AvaticaStatement.execute(AvaticaStatement.java:218)
>       at 
> org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.execute(JDBCStatementImpl.java:330)
>       at 
> org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.executeStatement(JDBCStatementImpl.java:131)
>       ... 12 more
> Caused by: java.lang.RuntimeException: java.net.SocketTimeoutException: Read 
> timed out
>       at 
> org.apache.calcite.avatica.remote.AvaticaCommonsHttpClientImpl.send(AvaticaCommonsHttpClientImpl.java:155)
>       at 
> org.apache.calcite.avatica.remote.RemoteService.apply(RemoteService.java:36)
>       at 
> org.apache.calcite.avatica.remote.JsonService.apply(JsonService.java:140)
>       at 
> org.apache.calcite.avatica.remote.RemoteMeta$14.call(RemoteMeta.java:310)
>       at 
> org.apache.calcite.avatica.remote.RemoteMeta$14.call(RemoteMeta.java:307)
>       at 
> org.apache.calcite.avatica.AvaticaConnection.invokeWithRetries(AvaticaConnection.java:795)
>       at 
> org.apache.calcite.avatica.remote.RemoteMeta.fetch(RemoteMeta.java:306)
>       at 
> org.apache.calcite.avatica.MetaImpl$FetchIterator.moveNext(MetaImpl.java:1643)
>       at 
> org.apache.calcite.avatica.MetaImpl$FetchIterator.<init>(MetaImpl.java:1611)
>       at 
> org.apache.calcite.avatica.MetaImpl$FetchIterator.<init>(MetaImpl.java:1586)
>       at 
> org.apache.calcite.avatica.MetaImpl$FetchIterable.iterator(MetaImpl.java:1581)
>       at org.apache.calcite.avatica.MetaImpl.createCursor(MetaImpl.java:98)
>       at 
> org.apache.calcite.avatica.AvaticaResultSet.execute(AvaticaResultSet.java:186)
>       at 
> org.apache.calcite.avatica.AvaticaConnection$1.execute(AvaticaConnection.java:669)
>       at 
> org.apache.calcite.avatica.remote.RemoteMeta$13.call(RemoteMeta.java:283)
>       at 
> org.apache.calcite.avatica.remote.RemoteMeta$13.call(RemoteMeta.java:263)
>       at 
> org.apache.calcite.avatica.AvaticaConnection.invokeWithRetries(AvaticaConnection.java:795)
>       at 
> org.apache.calcite.avatica.remote.RemoteMeta.prepareAndExecute(RemoteMeta.java:262)
>       at 
> org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:677)
>       at 
> org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:157)
>       ... 15 more
> Caused by: java.net.SocketTimeoutException: Read timed out
>       at java.base/sun.nio.ch.NioSocketImpl.timedRead(Unknown Source)
>       at java.base/sun.nio.ch.NioSocketImpl.implRead(Unknown Source)
>       at java.base/sun.nio.ch.NioSocketImpl.read(Unknown Source)
>       at java.base/sun.nio.ch.NioSocketImpl$1.read(Unknown Source)
>       at java.base/java.net.Socket$SocketInputStream.read(Unknown Source)
>       at 
> org.apache.hc.client5.http.impl.io.LoggingInputStream.read(LoggingInputStream.java:81)
>       at 
> org.apache.hc.core5.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:149)
>       at 
> org.apache.hc.core5.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:280)
>       at 
> org.apache.hc.core5.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:247)
>       at 
> org.apache.hc.core5.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:54)
>       at 
> org.apache.hc.core5.http.impl.io.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:299)
>       at 
> org.apache.hc.core5.http.impl.io.HttpRequestExecutor.execute(HttpRequestExecutor.java:175)
>       at 
> org.apache.hc.core5.http.impl.io.HttpRequestExecutor.execute(HttpRequestExecutor.java:218)
>       at 
> org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager$InternalConnectionEndpoint.execute(PoolingHttpClientConnectionManager.java:712)
>       at 
> org.apache.hc.client5.http.impl.classic.InternalExecRuntime.execute(InternalExecRuntime.java:216)
>       at 
> org.apache.hc.client5.http.impl.classic.MainClientExec.execute(MainClientExec.java:116)
>       at 
> org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
>       at 
> org.apache.hc.client5.http.impl.classic.ConnectExec.execute(ConnectExec.java:188)
>       at 
> org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
>       at 
> org.apache.hc.client5.http.impl.classic.ProtocolExec.execute(ProtocolExec.java:192)
>       at 
> org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
>       at 
> org.apache.hc.client5.http.impl.classic.HttpRequestRetryExec.execute(HttpRequestRetryExec.java:96)
>       at 
> org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
>       at 
> org.apache.hc.client5.http.impl.classic.ContentCompressionExec.execute(ContentCompressionExec.java:152)
>       at 
> org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
>       at 
> org.apache.hc.client5.http.impl.classic.RedirectExec.execute(RedirectExec.java:115)
>       at 
> org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
>       at 
> org.apache.hc.client5.http.impl.classic.InternalHttpClient.doExecute(InternalHttpClient.java:170)
>       at 
> org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:106)
>       at 
> org.apache.calcite.avatica.remote.AvaticaCommonsHttpClientImpl.execute(AvaticaCommonsHttpClientImpl.java:163)
>       at 
> org.apache.calcite.avatica.remote.AvaticaCommonsHttpClientImpl.send(AvaticaCommonsHttpClientImpl.java:134)
>       ... 34 more
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to