[ 
https://issues.apache.org/jira/browse/DERBY-2026?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12897438#action_12897438
 ] 

Kathey Marsden commented on DERBY-2026:
---------------------------------------

DriverManager is pretty vague, but I am getting pretty confused on the various 
timeout options in DataSources and Sockets. For DataSource I see:

setLoginTimeout
 A value of zero specifies that the timeout is the default system timeout if 
there is one; otherwise, it specifies that there is no timeout. When a 
DataSource object is created, the login timeout is initially zero.

On Socket setSoTimout I see:
The timeout must be > 0. A timeout of zero is interpreted as an infinite 
timeout. 

So I guess according to spec with  setLoginTimeout set, after we make the 
connection, it should restore things to the system default, not call 
setSoTimeout(0) to make it infinite but I don't actually see an option to do 
that with setSoTimeout on the socket.  

Furthermore, I have a report from a user using the existing code that is seeing 
timeouts on queries after calling setLoginTimeout(0) which I think should 
change things to an 
infinite timeout but does not appear to be doing so.  Of course if that is the 
case, neither Mamta's fix nor restoring to the default after the connection 
would help them.  

Sorry for the rambling. I will do some experiments on my machine and hopefully 
get access to the user's to try and  understand all this better.   Any comments 
of pearls of wisdom in this area are welcome.




> Setting a login timeout in client driver can lead to query timeout
> ------------------------------------------------------------------
>
>                 Key: DERBY-2026
>                 URL: https://issues.apache.org/jira/browse/DERBY-2026
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC, Network Client
>    Affects Versions: 10.3.1.4
>         Environment: Client driver on most platforms
>            Reporter: Olav Sandstaa
>            Assignee: Mamta A. Satoor
>            Priority: Minor
>         Attachments: DERBY2026_LoginTimeout_diff_patch1.txt, LoginTimeout.java
>
>
> Setting the login timeout by using DriverManager.setLoginTimeout(int
> seconds) also affects the amount of time the client driver is waiting
> for a query to finish. For instance, setting the login timeout to 10
> seconds will result in any queries taking more than 10 seconds to fail
> with the following exception:
> Exception thrown: java.sql.SQLException: A communications error has been 
> detected: Read timed out.
> java.sql.SQLException: A communications error has been detected: Read timed 
> out.
>         at 
> org.apache.derby.client.am.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:46)
>         at 
> org.apache.derby.client.am.SqlException.getSQLException(SqlException.java:345)
>         at 
> org.apache.derby.client.am.Statement.executeQuery(Statement.java:414)
>         at LoginTimeout.main(LoginTimeout.java:53)
> Caused by: org.apache.derby.client.am.DisconnectException: A communications 
> error has been detected: Read timed out.
>         at 
> org.apache.derby.client.net.NetAgent.throwCommunicationsFailure(NetAgent.java:408)
>         at org.apache.derby.client.net.Reply.fill(Reply.java:176)
>         at 
> org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Reply.java:215)
>         at org.apache.derby.client.net.Reply.readDssHeader(Reply.java:317)
>         at 
> org.apache.derby.client.net.Reply.startSameIdChainParse(Reply.java:1147)
>         at 
> org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(NetStatementReply.java:51)
>         at 
> org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(StatementReply.java:40)
>         at 
> org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(NetStatement.java:139)
>         at 
> org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Statement.java:1341)
>         at 
> org.apache.derby.client.am.Statement.flowExecute(Statement.java:1977)
>         at 
> org.apache.derby.client.am.Statement.executeQueryX(Statement.java:420)
>         at 
> org.apache.derby.client.am.Statement.executeQuery(Statement.java:405)
>         ... 1 more
> Caused by: java.net.SocketTimeoutException: Read timed out
>         at java.net.SocketInputStream.socketRead0(Native Method)
>         at java.net.SocketInputStream.read(SocketInputStream.java:129)
>         at org.apache.derby.client.net.Reply.fill(Reply.java:174)
>         ... 11 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to