pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Magnus Hagander <magnus@hagander.net>
Cc: Amit Kapila <amit.kapila16@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: Why doesn't src/backend/port/win32/socket.c implement bind()?
Date: Tue, 12 Apr 2016 20:06:16 -0400
Message-ID: <23991.1460505976@sss.pgh.pa.us> (raw)
In-Reply-To: <CABUevExPNDmQWT9H2GSs72G5itjx0ow7e_A8Djg38o2oNH-zvw@mail.gmail.com>
References: <4065.1452450340@sss.pgh.pa.us>
	<CAA4eK1L75jQgDY6PL5pSh9OxmDx5eYZX+E5YFZVWVyUXB9ZuEQ@mail.gmail.com>
	<CABUevExPNDmQWT9H2GSs72G5itjx0ow7e_A8Djg38o2oNH-zvw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Magnus Hagander <magnus@hagander.net> writes:
> On Mon, Jan 11, 2016 at 6:19 AM, Amit Kapila <amit.kapila16@gmail.com>
> wrote:
>> On Sun, Jan 10, 2016 at 11:55 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>> I think the reason why we're getting "No error" instead of a useful
>>> strerror report is that socket.c doesn't provide an implementation
>>> of bind() that includes TranslateSocketError().

>> listen also doesn't have such an implementation and probably few others.
>> I think here we should add a win32 wrapper over bind and listen
>> API's which ensures TranslateSocketError() should be called for
>> error cases.

> Yeah, that seems like a good idea.

I finally got around to doing this, after being annoyed by yet another
Windows buildfarm failure with no clear indication as to the cause:
http://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=bowerbird&dt=2016-04-12%2022%3A30%3A12

While we wait to see if that actually helps give useful errors,
I had a thought about what may be happening here.  PostgresNode.pm
picks a random high port number and tests to see if it's free using
pg_isready, with (unless I'm misreading) any non-zero result code
being taken as "it's free".  The problem here is that that completely
fails to recognize a port being used by a non-Postgres process as
not-free --- most likely, you'll get PQPING_NO_RESPONSE for that case.
If there's other stuff using high ports on a particular buildfarm machine,
you'd expect occasional random test failures due to this.  The observed
fact that some buildfarm critters are much more prone to this type of
failure than others is well explained by this hypothesis.

I think we should forget about pg_isready altogether here, and instead
write some code that either tries to bind() the target port number itself,
or tries a low-level TCP connection request to the target port.  I'm
not sure what's the most convenient way to accomplish either in Perl.

The bind() solution would provide a more trustworthy answer, but it
might actually create more problems than it solves if the OS requires a
cooling-off period before giving the port out to a different process.

			regards, tom lane


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



view thread (19+ messages)  latest in thread

Message-ID: <23991.1460505976@sss.pgh.pa.us>
Permalink:  ../23991.1460505976@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/23991.1460505976@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, magnus@hagander.net, amit.kapila16@gmail.com
  Subject: Re: Why doesn't src/backend/port/win32/socket.c implement bind()?
  In-Reply-To: <23991.1460505976@sss.pgh.pa.us>
  References: <4065.1452450340@sss.pgh.pa.us> <CAA4eK1L75jQgDY6PL5pSh9OxmDx5eYZX+E5YFZVWVyUXB9ZuEQ@mail.gmail.com> <CABUevExPNDmQWT9H2GSs72G5itjx0ow7e_A8Djg38o2oNH-zvw@mail.gmail.com> <23991.1460505976@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