Re: [BUGS] BUG #13611: test_postmaster_connection failed (Windows, listen_addresses = '0.0.0.0' or '::')

From: Noah Misch <noah(at)leadboat(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Tatsuo Ishii <ishii(at)postgresql(dot)org>, kondo(at)sraoss(dot)co(dot)jp, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [BUGS] BUG #13611: test_postmaster_connection failed (Windows, listen_addresses = '0.0.0.0' or '::')
Date: 2015-10-09 03:26:49
Message-ID: 20151009032649.GA62964@tornado.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Mon, Sep 14, 2015 at 12:36:14AM -0400, Tom Lane wrote:
> Tatsuo Ishii <ishii(at)postgresql(dot)org> writes:
> >> When pg_ctl tries to connect to postmaster, it uses "0.0.0.0" as the
> >> target ip address. Unfortunately "0.0.0.0" is not a valid address on
> >> Windows and it fails. Shouldn't pg_ctl translate "0.0.0.0" to
> >> "127.0.0.1" in this case?
>
> > I think this is definitely a bug. I privately heard from the reporter
> > that if postmaster is started by not using pg_ctl, it happily starts
> > with "listen_addresses = '0.0.0.0'. That means, postmaster itself
> > works as advertised, but pg_ctl does not.
>
> I looked at this before, and could not see anything in either the
> postmaster or pg_ctl that would invent the address 0.0.0.0 out of
> thin air. I think this report most likely depends on some
> misconfiguration of the OP's system. I doubt it should be our business
> to work around such misconfiguration.

Use of "0.0.0.0" or "::" as a socket destination address is not portable. The
Windows connect() documentation says, "If the address member of the structure
specified by the name parameter is filled with zeros, connect will return the
error WSAEADDRNOTAVAIL." OpenBSD 5.0 behaves the same way. NetBSD 6.0 does
not accept ::, but it accepts 0.0.0.0. (For this to affect pg_ctl on
non-Windows platforms, you would need to empty unix_socket_directories.)

> In particular, magically
> substituting 127.0.0.1 for 0.0.0.0 seems utterly without principle.

Binding a listening socket to "0.0.0.0" listens on every local IPv4 address,
and 127.0.0.1 is one of those addresses. That's the principle. It's
inelegant, but I expect it to work everywhere.

nm

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message oktogen 2015-10-09 07:43:34 BUG #13671: pg_terminate_backend(pid) does not work
Previous Message jpruitt 2015-10-08 22:34:05 BUG #13670: DST discrepancy between age() and subtraction for timestamptz arguments

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2015-10-09 04:00:12 Re: Support for N synchronous standby servers - take 2
Previous Message Stephen Frost 2015-10-09 03:04:46 Re: Multi-tenancy with RLS