Skip site navigation (1) Skip section navigation (2)

Re: Implementing setQueryTimeout()

From: Till Toenges <tt(at)kyon(dot)de>
To: Oliver Jowett <oliver(at)opencloud(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Gregory Stark <stark(at)enterprisedb(dot)com>, PostgreSQL - JDBC <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Implementing setQueryTimeout()
Date: 2008-02-19 09:13:37
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
Oliver Jowett wrote:
>>> Sorry. Of course the driver must handle failed connections. I meant 
>>> the code in my application, which handles the two cases (timeout but 
>>> usable connection vs broken connection for whatever reason) differently.
>> You can check the SQLState of any exception thrown to tell the 
>> difference, right?

Yes, i can check that. But if the connection is closed at this point, 
that's no longer useful, except for diagnostics. This is, of course, 
just the case where setQueryTimeout() is really "hard".

> Just to clarify:
> - If the soft query timeout goes off and the server cancels the query, 
> you will get a server-generated SQLException saying the query was 
> cancelled. This will be some non-fatal SQLState and generally looks like 
> any other SQL error generated by the server. The connection and 
> statement will still be live (and in fact IIRC the transaction is still 
> live and you can rollback to a savepoint, etc, if you like)
> - If the hard query timeout goes off, you will get a SQLException 
> generated by the driver that has whatever the SQLState for connection 
> errors is (I can't remember offhand) - but it will look very similar to 
> the exception you get for any other connection problem when running a 
> query.
> Basically the "hard query" timeout just introduces a new cause of 
> connection errors - "server didn't respond within the timeout". It will 
> otherwise behave like any other network-level connection error.

The distinction between hard and soft timeouts makes sense in this way. 
Please just make it so that hard timeouts are off by default.


In response to

pgsql-jdbc by date

Next:From: Gregory StarkDate: 2008-02-19 09:46:28
Subject: Re: Implementing setQueryTimeout() - round 2
Previous:From: Oliver JowettDate: 2008-02-19 08:46:38
Subject: Re: Implementing setQueryTimeout()

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group