Skip site navigation (1) Skip section navigation (2)

Re: keepalives on MacOS X

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: keepalives on MacOS X
Date: 2010-07-02 21:44:14
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
On Tue, Jun 29, 2010 at 10:53 PM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
> On Tue, Jun 29, 2010 at 11:28 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>> On Tue, Jun 29, 2010 at 12:42 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> Yeah, a bit of rooting around in the Darwin sources shows that this
>>> value is used as a per-connection override for tcp_keepidle.  So it
>>> is a synonym.  Not sure if it's worth supporting when the other value
>>> can't be set too.  Maybe it'd be more useful to document that people can
>>> set the system-wide values if they're desperate.
>> Well, the default value for tcp_keepidle is 2 hours, and the default
>> value for tcp_keepintvl is 75 seconds.  Assuming that tcp_keepcount
>> defaults to something reasonable (I think the default on Linux is 9),
>> the lion's share of the time will be waiting for tcp_keepidle - so
>> just the ability to reduce that value to something reasonable should
>> help a lot.  It's also not much code - proposed patch attached.
> src/interfaces/libpq/fe-connect.c
> +               appendPQExpBuffer(&conn->errorMessage,
> +                                                 libpq_gettext("setsockopt(TCP_KEEPIDLE) failed: %s\n"),
> +                                                 SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));


> Don't we need to change pq_getkeepalivesidle?

I changed this, but it doesn't seem to have done much.  When I do
"show tcp_keepalives_idle" on MacOS X, I still get 0.  gdb says
getsockopt is getting called, though.  Am I doing something boneheaded
here, or is this just the behavior?

> In pq_setkeepalivesidle, if neither TCP_KEEPIDLE nor TCP_KEEPALIVE are
> supported, the following message is output.
>    setsockopt(TCP_KEEPIDLE) not supported


Robert Haas
The Enterprise Postgres Company

Attachment: tcp_keepalive_for_keepidle-v2.patch
Description: application/octet-stream (4.9 KB)

In response to


pgsql-hackers by date

Next:From: Robert HaasDate: 2010-07-02 21:47:20
Subject: Re: warning message in standby
Previous:From: Bruce MomjianDate: 2010-07-02 21:12:22
Subject: Re: No hash join across partitioned tables?

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group