Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZppEG-0007x9-C4 for pgsql-hackers@arkaria.postgresql.org; Sat, 24 Oct 2015 03:10:48 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZppEF-0001IJ-OJ for pgsql-hackers@arkaria.postgresql.org; Sat, 24 Oct 2015 03:10:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZppED-0001Dd-Ak for pgsql-hackers@postgresql.org; Sat, 24 Oct 2015 03:10:45 +0000 Received: from mail-qg0-x22f.google.com ([2607:f8b0:400d:c04::22f]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1ZppEA-0003Nj-1x for pgsql-hackers@postgresql.org; Sat, 24 Oct 2015 03:10:44 +0000 Received: by qgad10 with SMTP id d10so81559747qga.3 for ; Fri, 23 Oct 2015 20:10:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=9Zvr/z+wpwY82/GvNKDtvwJnMUqEAjlwyaDS4tP6owI=; b=NnAw2Xxgyk/vQkKT9xWTIIw4HoRtxm9bLlXlKsTSDObp5SPeAQvWufqfuVmGPTvGwn ewNCByMzhdt0KyS06OiSNX1gMfEOUUSGrIs2TXPQBT/1nfLo6ETxPlBldw6mpmp6QLVX jxtzYHv6L2/XO3eVMPXx5qUMvO5uzaZp+lNXY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=9Zvr/z+wpwY82/GvNKDtvwJnMUqEAjlwyaDS4tP6owI=; b=Dfn5kwdMZl6f1lx0LqvaDFl+Zu5Yy9YyPbn7MdDLsvbTciNxgurca8VsrGaGTVqj6+ WP27A5p9FH9SAp1Am3zbuqRk5fKlEOQ2sFqUyYdsV+kqfa4ohDfnAjRgAla82ZADaTQI i/c8nUdeAwES4xuDWFStx/ns3vaxWNQAOoWR+UsMcwTnVHmwCU/vL7NfQ69+5sWKUzuy +i0YBiKL5nMnIMvrs62XQ3ri/J8f+8vBqa7foyer5lyaaP6fcng2suq4casHQVjKvPtY kjBPJzwKwvOmtNB1neBdM/PRLHvOYeAo7fD1J7zNpTMFiwc2DozFhhHK+k2ER0ljXJ48 KjCA== X-Gm-Message-State: ALoCoQkYPyTA1wgdB7EO6TvIe3V/x/RCanNIefDbmhrkG7jMv8Pyq5HipYOIuxh1bF8y24MffE4l X-Received: by 10.140.234.134 with SMTP id f128mr23092978qhc.43.1445656240331; Fri, 23 Oct 2015 20:10:40 -0700 (PDT) Received: from tornado.leadboat.com (c-98-248-47-228.hsd1.ca.comcast.net. [98.248.47.228]) by smtp.gmail.com with ESMTPSA id k136sm8656276qhk.2.2015.10.23.20.10.38 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 23 Oct 2015 20:10:39 -0700 (PDT) Date: Fri, 23 Oct 2015 23:10:36 -0400 From: Noah Misch To: Tom Lane Cc: Tatsuo Ishii , robertmhaas@gmail.com, kondo@sraoss.co.jp, pgsql-hackers@postgresql.org Subject: Re: Re: [BUGS] BUG #13611: test_postmaster_connection failed (Windows, listen_addresses = '0.0.0.0' or '::') Message-ID: <20151024031036.GB421105@tornado.leadboat.com> References: <1815.1444694857@sss.pgh.pa.us> <20151013020831.GC164717@tornado.leadboat.com> <20151023.080042.393745468058207046.t-ishii@sraoss.co.jp> <53500.1445555710@sss.pgh.pa.us> <20151023005147.GA403745@tornado.leadboat.com> <55164.1445569167@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55164.1445569167@sss.pgh.pa.us> User-Agent: Mutt/1.5.23 (2014-03-12) X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On Thu, Oct 22, 2015 at 07:59:27PM -0700, Tom Lane wrote: > Noah Misch writes: > > pg_ctl reads the address from postmaster.pid, which in turn derives from > > listen_addresses: > > > $ grep -E '(unix|listen)' postgresql.conf > > listen_addresses = '0.0.0.0' > > unix_socket_directories = '' > > Hmm, now I see. I was about to object that that's a pretty silly setting, > but I see that we actually document it as supported. > > > $ strace -e connect pg_ctl -D . -w start > > --- SIGCHLD (Child exited) @ 0 (0) --- > > waiting for server to start...connect(3, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory) > > connect(3, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory) > > connect(3, {sa_family=AF_INET, sin_port=htons(6432), sin_addr=inet_addr("0.0.0.0")}, 16) = -1 EINPROGRESS (Operation now in progress) > > 403978 2015-10-23 00:45:06.677 GMT LOG: redirecting log output to logging collector process > > 403978 2015-10-23 00:45:06.677 GMT HINT: Future log output will appear in directory "..". > > done > > server started > > Process 403975 detached > > ... although this trace appears to show pg_ctl working just fine with this > setting, which kinda weakens your theory. Still, it wouldn't be the first > thing we've seen fail on Windows but work elsewhere. As I stated upthread, PQping("host='0.0.0.0'") is _not portable_. It works on GNU/Linux, which I used for that demo. It fails on OpenBSD and Windows. > I'd be inclined to suggest fixing it like this: > > /* If postmaster is listening on "*", use localhost */ > - if (strcmp(host_str, "*") == 0) > + if (strcmp(host_str, "*") == 0 || > + strcmp(host_str, "0.0.0.0") == 0 || > + strcmp(host_str, "::") == 0) > strcpy(host_str, "localhost"); > > which covers the cases we document as supported. On RHEL 5 and some other "active adult" systems, "localhost" does not reach a listen_addresses='::' server. IPv6 is available, but "localhost" resolves to 127.0.0.1 only. The latest systems resolve "localhost" to both 127.0.0.1 and ::1, in which case PQping("host='localhost'") will attempt both addresses in an unspecified order. Given a postmaster with listen_addresses='0.0.0.0', contacting ::1 first will fail (fine) or reach a different postmaster (not fine). Kondo's design is correct. > A different line of thought would be to teach the postmaster to record > actually bound-to addresses in postgresql.conf, rather than regurgitating > the listen_addresses setting verbatim. That would likely be a lot harder > (and less portable); though if we think there's anything besides pg_ctl > looking at this field, it might be worth trying. Binding to INADDR_ANY is not equivalent to binding to some list of concrete addresses. nm -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers