pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: Gregory Stark <stark@enterprisedb.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL - JDBC <pgsql-jdbc@postgresql.org>
Subject: Re: Implementing setQueryTimeout()
Date: Tue, 19 Feb 2008 14:01:34 +1300
Message-ID: <47BA2A6E.6050907@opencloud.com> (raw)
In-Reply-To: <87ejbao6bg.fsf@oxford.xeocode.com>
References: <47B8E200.2020307@opencloud.com>
	<5350.1203299903@sss.pgh.pa.us>
	<47B8EB1C.8090802@opencloud.com>
	<87ejbao6bg.fsf@oxford.xeocode.com>

Gregory Stark wrote:

> The problem of a broken network connection or down server is another case. For
> most users without a failover server I think triggering an error in this case
> would actually do more harm than good. Even with a failover in my experience
> you really want a manual or out-of-band mechanism to trigger failover lest you
> get false positives or double-failures.

It is not about triggering failover in my scenario, it is about limiting 
the time a thread can spend blocked waiting on a query.

The scenario is call processing where access to the DB is not critical - 
you can do something acceptable without DB access. However, what you do 
*not* have the luxury of doing is hanging around for 5 minutes waiting 
for a connection to time out before you make a decision about what to do 
with the call! Instead you want a rapid error, mark the DB as down, and 
future queries proceed as if the DB has failed until a separate check 
process manages to run a test query against the DB successfully.

There is a secondary problem that you do not have an unbounded number of 
threads and connections to do your processing on, so tying up threads 
and connections blocking on a slowly dying TCP connection is a real 
problem - under any real load you will exhaust your thread pool (or 
connection pool) in a matter of seconds. Then everything stops. This is bad.

I can implement something in my local copy of the driver to support 
this, but it'd be nice if I can do something more generally useful too..

I'd argue that "close connection on network timeout if setQueryTimeout() 
is set" is better than "do absolutely nothing special if 
setQueryTimeout() is set", anyway. If you don't want queries being 
aborted because they are taking too long to complete.. don't set a query 
timeout!

-O




view thread (16+ messages)  latest in thread

Message-ID: <47BA2A6E.6050907@opencloud.com>
Permalink:  ../47BA2A6E.6050907@opencloud.com/
Also on:    postgresql.org/message-id/47BA2A6E.6050907@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, stark@enterprisedb.com, tgl@sss.pgh.pa.us
  Subject: Re: Implementing setQueryTimeout()
  In-Reply-To: <47BA2A6E.6050907@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>

* 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