Lists: | pgsql-hackers |
---|
From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | keepalives on MacOS X |
Date: | 2010-06-28 19:07:42 |
Message-ID: | AANLkTim1omBQ4U-Ib5VoOoWbbuU8COh9G2rJdqUkIlVr@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | Postg와이즈 토토SQL |
It looks like the recent keepalives patch won't support MacOS X,
because MacOS X does not have the TCP_KEEPIDLE, TCP_KEEPINTVL, and
TCP_KEEPCNT socket parameters. It does have this:
#define TCP_KEEPALIVE 0x10 /* idle time used when
SO_KEEPALIVE is enabled */
Should we try to support that as a synonym for TCP_KEEPIDLE, if that's
what it is? Or not worry about it? Or... what?
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company
From: | Fujii Masao <masao(dot)fujii(at)gmail(dot)com> |
---|---|
To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: keepalives on MacOS X |
Date: | 2010-06-29 03:48:08 |
Message-ID: | AANLkTinRTXN9EPfNaN0dhUyculeDog5rAa4qliwWMclb@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Tue, Jun 29, 2010 at 4:07 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> It looks like the recent keepalives patch won't support MacOS X,
> because MacOS X does not have the TCP_KEEPIDLE, TCP_KEEPINTVL, and
> TCP_KEEPCNT socket parameters. It does have this:
>
> #define TCP_KEEPALIVE 0x10 /* idle time used when
> SO_KEEPALIVE is enabled */
>
> Should we try to support that as a synonym for TCP_KEEPIDLE, if that's
> what it is? Or not worry about it? Or... what?
I'm not sure that can be a synonym for TCP_KEEPIDLE, but if so we should
change not only a client-side but also server-side.
Regards,
--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: keepalives on MacOS X |
Date: | 2010-06-29 04:42:22 |
Message-ID: | 10707.1277786542@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> It looks like the recent keepalives patch won't support MacOS X,
> because MacOS X does not have the TCP_KEEPIDLE, TCP_KEEPINTVL, and
> TCP_KEEPCNT socket parameters. It does have this:
It looks to me like there's support for setting KEEPIDLE and KEEPINTVL
via sysctl, but of course that's system-wide and presumably requires
root privilege to set. (Apple seems to have inherited that from various
BSDen, btw; it's not unique to Darwin.)
> #define TCP_KEEPALIVE 0x10 /* idle time used when
> SO_KEEPALIVE is enabled */
> Should we try to support that as a synonym for TCP_KEEPIDLE, if that's
> what it is? Or not worry about it? Or... what?
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.
regards, tom lane
From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: keepalives on MacOS X |
Date: | 2010-06-29 14:28:33 |
Message-ID: | AANLkTimXNKYlm9dnynIceskHoNP4-RQNLrdpLbX9YrDq@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
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.
Some documentation of how to change this stuff via sysctl on various
OSes wouldn't be a bad thing either - anyone feel like writing
something up?
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company
Attachment | Content-Type | Size |
---|---|---|
tcp_keepalive_for_keepidle.patch | application/octet-stream | 3.7 KB |
From: | Fujii Masao <masao(dot)fujii(at)gmail(dot)com> |
---|---|
To: | Robert Haas <robertmhaas(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-06-30 02:53:33 |
Message-ID: | AANLkTinIMZ_7y6gX_N0uW74qha-dE2luFW-O5qIQSjYK@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
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)));
s/TCP_KEEPIDLE/TCP_KEEPALIVE
Don't we need to change pq_getkeepalivesidle?
In pq_setkeepalivesidle, if neither TCP_KEEPIDLE nor TCP_KEEPALIVE are
supported, the following message is output.
setsockopt(TCP_KEEPIDLE) not supported
We should change it to something like?
neither setsockopt(TCP_KEEPIDLE) nor setsockopt(TCP_KEEPALIVE) are supported
Regards,
--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center
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: | AANLkTinm7xiE2hq_Wlyayx80QAkZqo4A4_pve2asbLhX@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
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)));
>
> s/TCP_KEEPIDLE/TCP_KEEPALIVE
Fixed.
> 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
Fixed.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company
Attachment | Content-Type | Size |
---|---|---|
tcp_keepalive_for_keepidle-v2.patch | application/octet-stream | 4.9 KB |
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-06 21:20:40 |
Message-ID: | AANLkTinbq-J41Jo5LQjEFgMaCgwodtkyr91c6uDRDEpq@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Fri, Jul 2, 2010 at 5:44 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> 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)));
>>
>> s/TCP_KEEPIDLE/TCP_KEEPALIVE
>
> Fixed.
>
>> 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
>
> Fixed.
Committed, after some further testing.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company