pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: lizenko79@gmail.com, Michael Paquier <michael.paquier@gmail.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #14720: getsockopt(TCP_KEEPALIVE) failed: Option not supported by protocol
Date: Wed, 28 Jun 2017 09:52:36 -0400
Message-ID: <8594.1498657956@sss.pgh.pa.us> (raw)
In-Reply-To: <1982.1498602401@sss.pgh.pa.us>
References: <20170627191732.bqh677xgt5bbdo7t@alvherre.pgsql>
	<20527.1498594613@sss.pgh.pa.us>
	<1982.1498602401@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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



view thread (7+ messages)

Message-ID: <8594.1498657956@sss.pgh.pa.us>
Permalink:  ../8594.1498657956@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/8594.1498657956@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, alvherre@2ndquadrant.com, michael.paquier@gmail.com
  Subject: Re: BUG #14720: getsockopt(TCP_KEEPALIVE) failed: Option not supported by protocol
  In-Reply-To: <8594.1498657956@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox