Re: proposal: setKeepAlive

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Oliver Jowett" <oliver(at)opencloud(dot)com>
Cc: "Toru SHIMOGAKI" <shimogaki(dot)toru(at)oss(dot)ntt(dot)co(dot)jp>, <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: proposal: setKeepAlive
Date: 2008-02-09 23:18:23
Message-ID: 87zlu9k9c0.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

"Oliver Jowett" <oliver(at)opencloud(dot)com> writes:

> Gregory Stark wrote:
>
>> TCP is supposed to work even if the network disappears and then reappears
>> later, gracefully handling intermittent network failures. The case where you
>> want to close connections which doesn't respond quickly is when you have hosts
>> (usually clients, which makes it strange to want this in a database client
>> driver) which are frequently permanently unplugged or renumbered such as
>> dialup users. That's why it's important for ftp servers or web servers.
>
> People seem to like to put stateful firewalls with low connection activity
> timeouts between their DB server and client. We get regular traffic on the list
> from people who see connections get reset on their first use after a long idle
> period. Presumably TCP keepalive would help in some of these cases.

With such broken routers keepalives won't actually help unless you set much
more aggressive times than the defaults which are required to be at least 2
hours. And of course the more aggressive you make them the more likely you are
to get spurious errors from an intermittent failure.

> Also, usually DB connections are local and you don't really want to plaster
> over the fact that the other end has gone MIA.

The local case is precisely where you wouldn't want to use keep-alives. When
the server does come back up you'll get RSET packets and the connections will
die. It's only in the remote case where you might never speak to the host
again or he may have been renumbered or permanently disconnected and there
might be no host with the old ip address at all that you might want to use
keep-alives.

> Keepalive helps a little but it's certainly not perfect. I ended up doing
> all the dead server detection at a higher level in the end.

I think you're doing exactly what you have to do. You certainly don't want to
predicate failover on simple network reachability. You want to base it on the
application actually functioning. Network reachability is both too sensitive
(keep-alive packets could be dropped due to congestion) and not sensitive
enough (if the application crashes the host may still be reachable).

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Ask me about EnterpriseDB's RemoteDBA services!

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Oliver Jowett 2008-02-09 23:27:25 Re: proposal: setKeepAlive
Previous Message Tom Lane 2008-02-09 23:01:42 Re: proposal: setKeepAlive