Re: BUG #14720: getsockopt(TCP_KEEPALIVE) failed: Option not supported by protocol
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: lizenko79@gmail.com, Michael Paquier <michael.paquier@gmail.com>,
pgsql-bugs@postgresql.org
Date: 2017-06-28T13:52:36Z
Lists: pgsql-bugs
I wrote:
> Concretely, something like the attached. I have no way to test this
> locally, so I'm thinking of just pushing it and seeing what the buildfarm
> says.
So that didn't work: castoroides is still showing
[5953a7e1.1fff:13] LOG: getsockopt(TCP_KEEPALIVE) failed: Option not supported by protocol
[5953a7e1.1fff:14] STATEMENT: select name, setting from pg_settings where name like 'enable%';
which implies that TCP_KEEPALIVE_THRESHOLD doesn't exist on Solaris 10.
Evidently, the logic here needs to be along the lines of
#if defined(TCP_KEEPIDLE)
...
#elif defined(TCP_KEEPALIVE_THRESHOLD)
...
#elif defined(TCP_KEEPALIVE) && defined(__darwin__)
...
Or we could make the last test be !defined(__solaris__), but I'm not
sure that's better. Anybody have an opinion?
As long as I have to touch this code again anyway, I'm also going to
look into Michael's thought of trying to reduce code duplication.
I was unhappy yesterday about how to handle the error messages,
but we could do it like this:
#if defined(TCP_KEEPIDLE)
#define PG_TCP_KEEPALIVE TCP_KEEPIDLE
#define PG_TCP_KEEPALIVE_STR "TCP_KEEPIDLE"
#elif ...
#ifdef PG_TCP_KEEPALIVE
if (setsockopt(port->sock, IPPROTO_TCP, PG_TCP_KEEPALIVE,
(char *) &idle, sizeof(idle)) < 0)
{
elog(LOG, "setsockopt(%s) failed: %m", PG_TCP_KEEPALIVE_STR);
which doesn't seem too painful.
regards, tom lane
Commits
-
Second try at fixing tcp_keepalives_idle option on Solaris.
- e97b7372bf94 9.4.13 landed
- cc154d9a0022 9.3.18 landed
- 99255d73c07c 10.0 landed
- 63f5db8ab7e7 9.5.8 landed
- 5e7447132000 9.2.22 landed
- 43c67e32fb29 9.6.4 landed
-
Support tcp_keepalives_idle option on Solaris.
- f0256c774daa 10.0 landed
- d16e96fb2aa1 9.5.8 landed
- c2cb606a2ead 9.4.13 landed
- 9ce7f39195dc 9.3.18 landed
- 6ccab9242b34 9.2.22 landed
- 55968ed89496 9.6.4 landed