From: Craig Ringer <ringerc@ringerc.id.au>
To: Samuel Gendler <sgendler@ideasculptor.com>
Cc: Oliver Jowett <oliver@opencloud.com>
Cc: Magosányi Árpád <mag@magwas.rulez.org>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: This connection has been closed
Date: Wed, 07 Dec 2011 12:30:06 +0800
Message-ID: <4EDEEBCE.40204@ringerc.id.au> (raw)
In-Reply-To: <CAEV0TzC=GHv+hvZtFp-hu8KGy0B-AE3oFv=iBeqo0df9LCbw+w@mail.gmail.com>
References: <4EDDB1B8.70203@magwas.rulez.org>
<CA+0W9LMVMvVh84ztm5CQVvSRj0N85kFGRN4Sv834DEuRm7Q-yA@mail.gmail.com>
<CAEV0TzC=GHv+hvZtFp-hu8KGy0B-AE3oFv=iBeqo0df9LCbw+w@mail.gmail.com>
On 06/12/11 15:55, Samuel Gendler wrote:
>
> If you're using a 3rd party connection pool, I don't believe there is
> a contract that they will necessarily validate that a connection is
> still open before returning it. Most pools can be configured to issue
> a 'select 1' type of query on a periodic basis to keep connections
> from timing out, or just to validate that a connection is still alive
> before returning it from the pool.
>
Relying on that alone is madness, because there's an inevitable gap
between the `SELECT 1;' succeeding and the connection being passed to
the app, and that's time the connection can become invalid during. It's
a race, bascially. Because that race can't be eliminated the app still
has to be coded to be fault-tolerant and cope with failed transactions.
Validating connections is still useful if your app's idea of
fault-tolerance is telling the user "something broke, please try again".
You want to minimise how often that happens, so you try to make sure
your pool notices a database restart promptly and flushes its connections.
If your app has better fault tolerance than that, where it remembers
what it tried to do and does it again if a transaction fails the first
time, then there may be no point validating connections at all.
--
Craig Ringer
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: ringerc@ringerc.id.au, sgendler@ideasculptor.com, oliver@opencloud.com, mag@magwas.rulez.org
Subject: Re: This connection has been closed
In-Reply-To: <4EDEEBCE.40204@ringerc.id.au>
References: <4EDDB1B8.70203@magwas.rulez.org> <CA+0W9LMVMvVh84ztm5CQVvSRj0N85kFGRN4Sv834DEuRm7Q-yA@mail.gmail.com> <CAEV0TzC=GHv+hvZtFp-hu8KGy0B-AE3oFv=iBeqo0df9LCbw+w@mail.gmail.com> <4EDEEBCE.40204@ringerc.id.au>
* 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