Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 2B64F2E3FD1 for ; Sat, 9 Feb 2008 19:35:00 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 16883-01-6 for ; Sat, 9 Feb 2008 19:34:49 -0400 (AST) Received: from oxford.xeocode.com (unknown [87.127.95.196]) by postgresql.org (Postfix) with ESMTP id D121A2E50E8 for ; Sat, 9 Feb 2008 19:18:27 -0400 (AST) Received: from localhost ([127.0.0.1] helo=oxford.xeocode.com) by oxford.xeocode.com with esmtp (Exim 4.69) (envelope-from ) id 1JNyxj-0003xB-M9; Sat, 09 Feb 2008 23:18:23 +0000 To: "Oliver Jowett" Cc: "Toru SHIMOGAKI" , Subject: Re: proposal: setKeepAlive In-Reply-To: <47AE2D07.50904@opencloud.com> (Oliver Jowett's message of "Sun\, 10 Feb 2008 11\:45\:27 +1300") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) X-Draft-From: ("nnimap+mail01.enterprisedb.com:INBOX" 63479) References: <47AC666C.9070704@oss.ntt.co.jp> <87abmb2weo.fsf@oxford.xeocode.com> <47AE2D07.50904@opencloud.com> From: Gregory Stark Organization: EnterpriseDB Date: Sat, 09 Feb 2008 23:18:23 +0000 Message-ID: <87zlu9k9c0.fsf@oxford.xeocode.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/29 X-Sequence-Number: 18236 "Oliver Jowett" 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!