pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: Till Toenges <tt@kyon.de>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Gregory Stark <stark@enterprisedb.com>
Cc: PostgreSQL - JDBC <pgsql-jdbc@postgresql.org>
Subject: Re: Implementing setQueryTimeout()
Date: Tue, 19 Feb 2008 21:46:38 +1300
Message-ID: <47BA976E.9030004@opencloud.com> (raw)
In-Reply-To: <47BA9626.5060209@opencloud.com>
References: <47B8E200.2020307@opencloud.com>
	<5350.1203299903@sss.pgh.pa.us>
	<47B8EB1C.8090802@opencloud.com>
	<87ejbao6bg.fsf@oxford.xeocode.com>
	<47BA2A6E.6050907@opencloud.com>
	<17814.1203384054@sss.pgh.pa.us>
	<47BA470A.8000904@opencloud.com>
	<47BA9284.5050407@kyon.de>
	<47BA92EA.1070201@opencloud.com>
	<47BA95D5.40408@kyon.de>
	<47BA9626.5060209@opencloud.com>

Oliver Jowett wrote:
> Till Toenges wrote:
>> Oliver Jowett wrote:
>>>> A network timeout or anything worse is handled in an entirely 
>>>> different part of the code. That is not the responsibility of the 
>>>> driver, and doesn't event need to be part of the database related 
>>>> code at all.
>>>
>>> I'm not sure what you mean here - if the connection to the DB fails, 
>>> the driver will certainly handle that and tell you about it via a 
>>> SQLException!
>>
>> 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?

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.

-O



view thread (16+ messages)  latest in thread

Message-ID: <47BA976E.9030004@opencloud.com>
Permalink:  ../47BA976E.9030004@opencloud.com/
Also on:    postgresql.org/message-id/47BA976E.9030004@opencloud.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: oliver@opencloud.com, tt@kyon.de, tgl@sss.pgh.pa.us, stark@enterprisedb.com
  Subject: Re: Implementing setQueryTimeout()
  In-Reply-To: <47BA976E.9030004@opencloud.com>
  References: <47B8E200.2020307@opencloud.com> <5350.1203299903@sss.pgh.pa.us> <47B8EB1C.8090802@opencloud.com> <87ejbao6bg.fsf@oxford.xeocode.com> <47BA2A6E.6050907@opencloud.com> <17814.1203384054@sss.pgh.pa.us> <47BA470A.8000904@opencloud.com> <47BA9284.5050407@kyon.de> <47BA92EA.1070201@opencloud.com> <47BA95D5.40408@kyon.de> <47BA9626.5060209@opencloud.com> <47BA976E.9030004@opencloud.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox