Re: [BUGS] BUG #14720: getsockopt(TCP_KEEPALIVE) failed: Option not supported by protocol - Mailing list pgsql-bugs

From Tom Lane
Subject Re: [BUGS] BUG #14720: getsockopt(TCP_KEEPALIVE) failed: Option not supported by protocol
Date
Msg-id 8594.1498657956@sss.pgh.pa.us
Whole thread Raw
In response to Re: [BUGS] BUG #14720: getsockopt(TCP_KEEPALIVE) failed: Option not supported by protocol  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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


--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

pgsql-bugs by date:

Previous
From: Amol Dongare
Date:
Subject: [BUGS] Multi-Master Replication
Next
From: bricklen
Date:
Subject: Re: [BUGS] Multi-Master Replication