Unix-domain socket support on Windows

Lists: pgsql-hackers
From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Unix-domain socket support on Windows
Date: 2019-08-07 13:56:03
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

It works!

(apparently as of Windows 10 version 1803)

Here are some patches to get a discussion rolling.

Basically, it just works, but you need to define your own struct
sockaddr_un. (This is what configure currently uses as a proxy for
HAVE_UNIX_SOCKETS, so (a) that needs a bit of tweaking, and (b) that is
the reason why builds haven't blown up already.)

But we'll now need to make things work so that binaries with Unix-domain
socket support work on systems without run-time support. We already did
that exercise with IPv6 support, so some of the framework is already in
place.

Depending on your Windows environment, there might not be a suitable
/tmp directory, so you'll need to specify a directory explicitly using
postgres -k or similar. This leads to the question what the default for
DEFAULT_PGSOCKET_DIR should be on Windows. I think it's probably best,
at least for now, to set it so that by default, neither server nor libpq
use Unix sockets unless explicitly selected. This can be done easily on
the server side by defining DEFAULT_PGSOCKET_DIR as "". But in libpq, I
don't think the code would handle that correctly everywhere, so it would
need some more analysis and restructuring possibly.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
0001-Enable-Unix-domain-sockets-support-on-Windows.patch text/plain 4.4 KB
0002-Sort-out-getpeereid-and-struct-passwd-handling-on-Wi.patch text/plain 5.4 KB
0003-psql-Remove-one-use-of-HAVE_UNIX_SOCKETS.patch text/plain 1.2 KB
0004-libpq-Remove-unnecessary-uses-of-HAVE_UNIX_SOCKETS.patch text/plain 1.7 KB
0005-initdb-Detect-Unix-domain-socket-support-dynamically.patch text/plain 8.4 KB

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Unix-domain socket support on Windows
Date: 2019-08-07 14:06:05
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 07/08/2019 16:56, Peter Eisentraut wrote:
> It works!

Cool!

Am I reading the patches correctly, that getpeereid() still doesn't work
on Windows? That means that peer authentication doesn't work, right?
That's a bit sad. One of the big advantages of unix domain sockets over
TCP is peer authentication.

- Heikki


From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Unix-domain socket support on Windows
Date: 2019-08-07 14:58:54
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 2019-08-07 16:06, Heikki Linnakangas wrote:
> Am I reading the patches correctly, that getpeereid() still doesn't work
> on Windows? That means that peer authentication doesn't work, right?
> That's a bit sad. One of the big advantages of unix domain sockets over
> TCP is peer authentication.

Correct, it's not supported. I think it's plausible that they will add
this in the future.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Unix-domain socket support on Windows
Date: 2019-08-07 15:15:59
Message-ID: CABUevEwW4dg8p4XKOO5a8dZ=J-XyTF+eCaQsAnRB1VEVLNLKYQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Aug 7, 2019 at 4:59 PM Peter Eisentraut <
peter(dot)eisentraut(at)2ndquadrant(dot)com> wrote:

> On 2019-08-07 16:06, Heikki Linnakangas wrote:
> > Am I reading the patches correctly, that getpeereid() still doesn't work
> > on Windows? That means that peer authentication doesn't work, right?
> > That's a bit sad. One of the big advantages of unix domain sockets over
> > TCP is peer authentication.
>
> Correct, it's not supported. I think it's plausible that they will add
> this in the future.
>

Does it work well enough that SSPI auth can run over it? SSPI auth with the
local provider gives you more or less the same results as peer, doesn't it?

--
Magnus Hagander
Me: https://www.hagander.net/ <http://www.hagander.net/>
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/>


From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Unix-domain socket support on Windows
Date: 2019-08-13 18:27:24
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 2019-08-07 15:56, Peter Eisentraut wrote:
> Depending on your Windows environment, there might not be a suitable
> /tmp directory, so you'll need to specify a directory explicitly using
> postgres -k or similar. This leads to the question what the default for
> DEFAULT_PGSOCKET_DIR should be on Windows. I think it's probably best,
> at least for now, to set it so that by default, neither server nor libpq
> use Unix sockets unless explicitly selected. This can be done easily on
> the server side by defining DEFAULT_PGSOCKET_DIR as "". But in libpq, I
> don't think the code would handle that correctly everywhere, so it would
> need some more analysis and restructuring possibly.

Updated patches, which now also address that issue: There is no default
socket dir on Windows and it's disabled by default on both client and
server.

Some comments on the patches:

v2-0001-Enable-Unix-domain-sockets-support-on-Windows.patch

This is pretty straightforward, apart from maybe some comments, but it
would need to be committed last, because it would enable all the Unix
socket related code on Windows, which needs to be fixed up by the
subsequent patches first.

v2-0002-Sort-out-getpeereid-and-struct-passwd-handling-on.patch

Maybe a more elegant way with fewer #ifdef WIN32 can be found?

v2-0003-psql-Remove-one-use-of-HAVE_UNIX_SOCKETS.patch

This could be committed independently.

v2-0004-libpq-Remove-unnecessary-uses-of-HAVE_UNIX_SOCKET.patch

This one as well.

v2-0005-initdb-Detect-Unix-domain-socket-support-dynamica.patch

I think this patch contains some nice improvements in general. How much
of that ends up being useful depends on how the subsequent patches (esp.
0007) end up, since with Unix-domain sockets disabled by default on
Windows, we won't need initdb doing any detection.

v2-0006-Fix-handling-of-Unix-domain-sockets-on-Windows-in.patch

This is a fairly independent and isolated change.

v2-0007-Disable-Unix-sockets-by-default-on-Windows.patch

This one is a bit complicated. Since there is no good default location
for Unix sockets on Windows, and many systems won't support them for
some time, the default implemented here is to not use them by default on
the server or client. This needs a fair amount of restructuring in the
to support the case of "supports Unix sockets but don't use them by
default", while maintaining the existing cases of "doesn't support Unix
sockets" and "use Unix sockets by default". There is some room for
discussion here.

This patch set needs testers with various Windows versions to test
different configurations, combinations, and versions.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
v2-0001-Enable-Unix-domain-sockets-support-on-Windows.patch text/plain 4.5 KB
v2-0002-Sort-out-getpeereid-and-struct-passwd-handling-on.patch text/plain 5.4 KB
v2-0003-psql-Remove-one-use-of-HAVE_UNIX_SOCKETS.patch text/plain 1.2 KB
v2-0004-libpq-Remove-unnecessary-uses-of-HAVE_UNIX_SOCKET.patch text/plain 1.7 KB
v2-0005-initdb-Detect-Unix-domain-socket-support-dynamica.patch text/plain 8.4 KB
v2-0006-Fix-handling-of-Unix-domain-sockets-on-Windows-in.patch text/plain 5.6 KB
v2-0007-Disable-Unix-sockets-by-default-on-Windows.patch text/plain 4.6 KB

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Unix-domain socket support on Windows
Date: 2019-09-02 23:45:27
Message-ID: CA+hUKGLkUTNjRZC9e4XjvLQCXL9Dre5ZQhoPqN+rZWbGYV1BQA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Aug 14, 2019 at 6:27 AM Peter Eisentraut
<peter(dot)eisentraut(at)2ndquadrant(dot)com> wrote:
> This patch set needs testers with various Windows versions to test
> different configurations, combinations, and versions.

It's failing to build on cfbot's AppVeyor setup[1]. That's currently
using Windows SDK 7.1, so too old for the new AF_UNIX sockets, but
presumably something is wrong because it shouldn't fail to compile and
link.

src/interfaces/libpq/fe-connect.c(2682): warning C4101: 'pwdbuf' :
unreferenced local variable [C:\projects\postgresql\libpq.vcxproj]
src/interfaces/libpq/fe-connect.c(2687): warning C4101: 'passerr' :
unreferenced local variable [C:\projects\postgresql\libpq.vcxproj]

fe-connect.obj : error LNK2019: unresolved external symbol getpeereid
referenced in function PQconnectPoll
[C:\projects\postgresql\libpq.vcxproj]

[1] https://ci.appveyor.com/project/postgresql-cfbot/postgresql/build/1.0.55034?fullLog=true

--
Thomas Munro
https://enterprisedb.com


From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Subject: Re: Unix-domain socket support on Windows
Date: 2019-09-03 07:24:14
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 2019-09-03 01:45, Thomas Munro wrote:
> fe-connect.obj : error LNK2019: unresolved external symbol getpeereid
> referenced in function PQconnectPoll
> [C:\projects\postgresql\libpq.vcxproj]

This should be fixed in the attached patches.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
v3-0001-Enable-Unix-domain-sockets-support-on-Windows.patch text/plain 4.5 KB
v3-0002-Sort-out-getpeereid-and-struct-passwd-handling-on.patch text/plain 6.0 KB
v3-0003-psql-Remove-one-use-of-HAVE_UNIX_SOCKETS.patch text/plain 1.2 KB
v3-0004-libpq-Remove-unnecessary-uses-of-HAVE_UNIX_SOCKET.patch text/plain 1.7 KB
v3-0005-initdb-Detect-Unix-domain-socket-support-dynamica.patch text/plain 8.4 KB
v3-0006-Fix-handling-of-Unix-domain-sockets-on-Windows-in.patch text/plain 5.6 KB
v3-0007-Disable-Unix-sockets-by-default-on-Windows.patch text/plain 4.6 KB

From: Alvaro Herrera from 2ndQuadrant <alvherre(at)alvh(dot)no-ip(dot)org>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Subject: Re: Unix-domain socket support on Windows
Date: 2019-09-06 15:02:24
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 2019-Sep-03, Peter Eisentraut wrote:

> On 2019-09-03 01:45, Thomas Munro wrote:
> > fe-connect.obj : error LNK2019: unresolved external symbol getpeereid
> > referenced in function PQconnectPoll
> > [C:\projects\postgresql\libpq.vcxproj]
>
> This should be fixed in the attached patches.

Minor bitrot in MSVC script; probably trivial to resolve.

I think you should get 0001 (+0002?) pushed and see what the buildfarm
thinks; move forward from there. 0003+0004 sound like they should just
be pushed shortly afterwards, while the three remaining ones might need
some more careful review.

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


From: Alvaro Herrera from 2ndQuadrant <alvherre(at)alvh(dot)no-ip(dot)org>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Subject: Re: Unix-domain socket support on Windows
Date: 2019-09-06 15:03:38
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 2019-Sep-06, Alvaro Herrera from 2ndQuadrant wrote:

> I think you should get 0001 (+0002?) pushed and see what the buildfarm
> thinks; move forward from there.

... but of course this goes counter to what you said earlier about 0001
needing to be pushed last.

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Unix-domain socket support on Windows
Date: 2019-10-30 12:02:07
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

To move this topic a long, I'll submit some preparatory patches in a
committable order.

First is the patch to deal with getpeereid() that was already included
in the previous patch series. This is just some refactoring that
reduces the difference between Windows and other platforms and prepares
the Unix-domain socket specific code to compile cleanly on Windows.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
v4-0001-Sort-out-getpeereid-and-peer-auth-handling-on-Win.patch text/plain 7.7 KB

From: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Unix-domain socket support on Windows
Date: 2019-12-16 04:39:55
Message-ID: CAA8=A7-VsWR9Z8Dg0XWTreP_x5=u2cXpGgJymy8-_yesEpHMFg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Oct 30, 2019 at 10:32 PM Peter Eisentraut
<peter(dot)eisentraut(at)2ndquadrant(dot)com> wrote:
>
> To move this topic a long, I'll submit some preparatory patches in a
> committable order.
>
> First is the patch to deal with getpeereid() that was already included
> in the previous patch series. This is just some refactoring that
> reduces the difference between Windows and other platforms and prepares
> the Unix-domain socket specific code to compile cleanly on Windows.
>

This looks fairly sane and straightforward. Let's give it an outing on
the buildfarm ASAP so we can keep moving forward on this.

cheers

andrew

--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Unix-domain socket support on Windows
Date: 2019-12-16 08:58:19
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 2019-12-16 05:39, Andrew Dunstan wrote:
> On Wed, Oct 30, 2019 at 10:32 PM Peter Eisentraut
> <peter(dot)eisentraut(at)2ndquadrant(dot)com> wrote:
>>
>> To move this topic a long, I'll submit some preparatory patches in a
>> committable order.
>>
>> First is the patch to deal with getpeereid() that was already included
>> in the previous patch series. This is just some refactoring that
>> reduces the difference between Windows and other platforms and prepares
>> the Unix-domain socket specific code to compile cleanly on Windows.
>>
>
>
> This looks fairly sane and straightforward. Let's give it an outing on
> the buildfarm ASAP so we can keep moving forward on this.

pushed

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Unix-domain socket support on Windows
Date: 2019-12-18 13:52:15
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Next patch: This allows building *with* Unix-domain socket support but
*without* a default Unix socket path. This is needed because on Windows
we don't have a good default location like "/tmp" and we probably don't
want Unix sockets by default at run time so that older Windows versions
continue to work out of the box with the same binaries.

We have code paths for Unix socket support and no Unix socket support.
Now add a third variant: Unix socket support but do not use a Unix
socket by default in the client or the server, only if you explicitly
specify one.

To implement this, tweak things so that setting DEFAULT_PGSOCKET_DIR
to "" has the desired effect. This mostly already worked like that;
only a few places needed to be adjusted. Notably, the reference to
DEFAULT_PGSOCKET_DIR in UNIXSOCK_PATH() could be removed because all
callers already resolve an empty socket directory setting with a
default if appropriate.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
v5-0001-Allow-building-without-default-socket-directory.patch text/plain 3.1 KB

From: "Hamlin, Garick L" <ghamlin(at)isc(dot)upenn(dot)edu>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Unix-domain socket support on Windows
Date: 2019-12-18 14:24:20
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Dec 18, 2019 at 02:52:15PM +0100, Peter Eisentraut wrote:
> To implement this, tweak things so that setting DEFAULT_PGSOCKET_DIR
> to "" has the desired effect. This mostly already worked like that;
> only a few places needed to be adjusted. Notably, the reference to
> DEFAULT_PGSOCKET_DIR in UNIXSOCK_PATH() could be removed because all
> callers already resolve an empty socket directory setting with a
> default if appropriate.

Would it make sense to support abstract sockets in PostgreSQL?

I know it's bit unrelated. I haven't read all the code here I just was
thinking about it because of the code checking the leading \0 byte of the dir.

Garick


From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: "Hamlin, Garick L" <ghamlin(at)isc(dot)upenn(dot)edu>
Cc: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Unix-domain socket support on Windows
Date: 2019-12-18 16:03:40
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 2019-12-18 15:24, Hamlin, Garick L wrote:
> On Wed, Dec 18, 2019 at 02:52:15PM +0100, Peter Eisentraut wrote:
>> To implement this, tweak things so that setting DEFAULT_PGSOCKET_DIR
>> to "" has the desired effect. This mostly already worked like that;
>> only a few places needed to be adjusted. Notably, the reference to
>> DEFAULT_PGSOCKET_DIR in UNIXSOCK_PATH() could be removed because all
>> callers already resolve an empty socket directory setting with a
>> default if appropriate.
>
> Would it make sense to support abstract sockets in PostgreSQL?

Maybe, I'm not sure.

> I know it's bit unrelated. I haven't read all the code here I just was
> thinking about it because of the code checking the leading \0 byte of the dir.

We would probably represent abstract sockets with a leading '@' in the
user-facing components and only translate it to the internal format at
the last moment, probably in that very same UNIXSOCK_PATH() function.
So I think that wouldn't be a problem.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Unix-domain socket support on Windows
Date: 2020-01-30 18:28:00
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 2019-12-18 14:52, Peter Eisentraut wrote:
> Next patch: This allows building *with* Unix-domain socket support but
> *without* a default Unix socket path. This is needed because on Windows
> we don't have a good default location like "/tmp" and we probably don't
> want Unix sockets by default at run time so that older Windows versions
> continue to work out of the box with the same binaries.
>
> We have code paths for Unix socket support and no Unix socket support.
> Now add a third variant: Unix socket support but do not use a Unix
> socket by default in the client or the server, only if you explicitly
> specify one.
>
> To implement this, tweak things so that setting DEFAULT_PGSOCKET_DIR
> to "" has the desired effect. This mostly already worked like that;
> only a few places needed to be adjusted. Notably, the reference to
> DEFAULT_PGSOCKET_DIR in UNIXSOCK_PATH() could be removed because all
> callers already resolve an empty socket directory setting with a
> default if appropriate.

Perhaps this patch is too boring to be reviewed. If there are no
objections, I'll commit it soon and then submit the final patches with
the real functionality for the next commit fest.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Unix-domain socket support on Windows
Date: 2020-01-30 18:41:36
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com> writes:
> On 2019-12-18 14:52, Peter Eisentraut wrote:
>> We have code paths for Unix socket support and no Unix socket support.
>> Now add a third variant: Unix socket support but do not use a Unix
>> socket by default in the client or the server, only if you explicitly
>> specify one.
>>
>> To implement this, tweak things so that setting DEFAULT_PGSOCKET_DIR
>> to "" has the desired effect. This mostly already worked like that;
>> only a few places needed to be adjusted. Notably, the reference to
>> DEFAULT_PGSOCKET_DIR in UNIXSOCK_PATH() could be removed because all
>> callers already resolve an empty socket directory setting with a
>> default if appropriate.

> Perhaps this patch is too boring to be reviewed. If there are no
> objections, I'll commit it soon and then submit the final patches with
> the real functionality for the next commit fest.

Sorry, I'd paid no particular attention to this thread because
I figured it'd take a Windows-competent person to review. But
the patch as it stands isn't that.

The code looks fine (and a big +1 for not having knowledge of
DEFAULT_PGSOCKET_DIR wired into UNIXSOCK_PATH). I wonder though
whether any user-facing documentation needs to be adjusted.

regards, tom lane


From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Unix-domain socket support on Windows
Date: 2020-01-31 06:10:41
Message-ID: CAMsr+YFe08zz+pysc9AW2ek2NcS9-MfbbYL+VNCEhNoxx1Jgzw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, 31 Jan 2020 at 02:41, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com> writes:
> > On 2019-12-18 14:52, Peter Eisentraut wrote:
> >> We have code paths for Unix socket support and no Unix socket support.
> >> Now add a third variant: Unix socket support but do not use a Unix
> >> socket by default in the client or the server, only if you explicitly
> >> specify one.
> >>
> >> To implement this, tweak things so that setting DEFAULT_PGSOCKET_DIR
> >> to "" has the desired effect. This mostly already worked like that;
> >> only a few places needed to be adjusted. Notably, the reference to
> >> DEFAULT_PGSOCKET_DIR in UNIXSOCK_PATH() could be removed because all
> >> callers already resolve an empty socket directory setting with a
> >> default if appropriate.
>
> > Perhaps this patch is too boring to be reviewed. If there are no
> > objections, I'll commit it soon and then submit the final patches with
> > the real functionality for the next commit fest.
>
> Sorry, I'd paid no particular attention to this thread because
> I figured it'd take a Windows-competent person to review. But
> the patch as it stands isn't that.
>
> The code looks fine (and a big +1 for not having knowledge of
> DEFAULT_PGSOCKET_DIR wired into UNIXSOCK_PATH). I wonder though
> whether any user-facing documentation needs to be adjusted.

Probably, since it won't work with 'peer' auth from what was said upthread.

--
Craig Ringer http://www.2ndQuadrant.com/
2ndQuadrant - PostgreSQL Solutions for the Enterprise


From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Unix-domain socket support on Windows
Date: 2020-01-31 16:55:58
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 2020-01-30 19:41, Tom Lane wrote:
> The code looks fine (and a big +1 for not having knowledge of
> DEFAULT_PGSOCKET_DIR wired into UNIXSOCK_PATH). I wonder though
> whether any user-facing documentation needs to be adjusted.

There are no user-facing changes in this patch yet. That will come with
subsequent patches.

This patch has now been committed.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Unix-domain socket support on Windows
Date: 2020-02-12 08:32:33
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Here is another patch set to enable this functionality.

0001 enables Unix-domain sockets on Windows, but leaves them turned off
by default at run time, using the mechanism introduced by a9cff89f7e.
This is relatively straightforward, except perhaps some aesthetic
questions about how these different configuration bits are distributed
around the various files.

0002 deals with pg_upgrade. It preserves the existing behavior of not
using Unix-domain sockets on Windows. This could perhaps be enhanced
later by either adding a command-line option or a run-time test. It's
too complicated right now.

0003 deals with how initdb should initialize postgresql.conf and
pg_hba.conf. It introduces a run-time test similar to how we detect
presence of IPv6. After I wrote this patch, I have come to think that
this is overkill and we should just always leave the "local" line in
pg_hba.conf even if there is no run-time support in the OS. (I think
the reason we do the run-time test for IPv6 is that we need it to parse
the IPv6 addresses in pg_hba.conf, but there is no analogous requirement
for Unix-domain sockets.) This patch is optional in any case.

0004 fixes a bug in the pg_upgrade test.sh script that was exposed by
these changes.

0005 fixes up some issues in the test suites. Right now, the TAP tests
are hardcoded to not use Unix-domain sockets on Windows, where as
pg_regress keys off HAVE_UNIX_SOCKETS, which is no longer a useful
distinguisher. The change is to not use Unix-domain sockets for all the
tests by default on Windows (the previous behavior) but give an option
to use them. At the moment, I would consider running the test suites
with Unix-domain sockets enabled as experimental, but that's only
because of various issues in the test setups. For instance, there is an
issue in the comment of pg_regress.c remove_temp() that I'm not sure how
to address. Also, the TAP tests don't seem to work because of some path
issues. I figured I'd call time on fiddling with this for now and ship
the patches.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
v6-0001-Enable-Unix-domain-sockets-support-on-Windows.patch text/plain 5.8 KB
v6-0002-pg_upgrade-Disable-Unix-domain-socket-support-on-.patch text/plain 1.8 KB
v6-0003-initdb-Detect-Unix-domain-socket-support-dynamica.patch text/plain 8.4 KB
v6-0004-Fix-pg_upgrade-test-for-Unix-domain-sockets-on-Wi.patch text/plain 1.7 KB
v6-0005-Allow-using-Unix-domain-sockets-on-Windows-in-tes.patch text/plain 6.9 KB

From: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Unix-domain socket support on Windows
Date: 2020-03-27 17:52:38
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers


On 2/12/20 3:32 AM, Peter Eisentraut wrote:
> Here is another patch set to enable this functionality.
>
> 0001 enables Unix-domain sockets on Windows, but leaves them turned
> off by default at run time, using the mechanism introduced by
> a9cff89f7e. This is relatively straightforward, except perhaps some
> aesthetic questions about how these different configuration bits are
> distributed around the various files.
>
> 0002 deals with pg_upgrade.  It preserves the existing behavior of not
> using Unix-domain sockets on Windows.  This could perhaps be enhanced
> later by either adding a command-line option or a run-time test.  It's
> too complicated right now.
>
> 0003 deals with how initdb should initialize postgresql.conf and
> pg_hba.conf.  It introduces a run-time test similar to how we detect
> presence of IPv6.  After I wrote this patch, I have come to think that
> this is overkill and we should just always leave the "local" line in
> pg_hba.conf even if there is no run-time support in the OS.  (I think
> the reason we do the run-time test for IPv6 is that we need it to
> parse the IPv6 addresses in pg_hba.conf, but there is no analogous
> requirement for Unix-domain sockets.)  This patch is optional in any
> case.
>
> 0004 fixes a bug in the pg_upgrade test.sh script that was exposed by
> these changes.
>
> 0005 fixes up some issues in the test suites.  Right now, the TAP
> tests are hardcoded to not use Unix-domain sockets on Windows, where
> as pg_regress keys off HAVE_UNIX_SOCKETS, which is no longer a useful
> distinguisher.  The change is to not use Unix-domain sockets for all
> the tests by default on Windows (the previous behavior) but give an
> option to use them.  At the moment, I would consider running the test
> suites with Unix-domain sockets enabled as experimental, but that's
> only because of various issues in the test setups.  For instance,
> there is an issue in the comment of pg_regress.c remove_temp() that
> I'm not sure how to address.  Also, the TAP tests don't seem to work
> because of some path issues.  I figured I'd call time on fiddling with
> this for now and ship the patches.
>

I have tested this on drongo/fairywren and it works fine. The patches
apply cleanly (with a bit of fuzz) and a full buildfarm run is happy in
both cases.

Unfortunately I don't have a Windows machine that's young enough to
support git master and old enough not to support Unix Domain sockets, so
i can't test that with socket-enabled binaries.

On inspection the patches seem fine.

Let's commit this and keep working on the pg_upgrade and test issues.

cheers

andrew

--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Unix-domain socket support on Windows
Date: 2020-03-30 15:43:12
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 2020-03-27 18:52, Andrew Dunstan wrote:
> I have tested this on drongo/fairywren and it works fine. The patches
> apply cleanly (with a bit of fuzz) and a full buildfarm run is happy in
> both cases.
>
> Unfortunately I don't have a Windows machine that's young enough to
> support git master and old enough not to support Unix Domain sockets, so
> i can't test that with socket-enabled binaries.
>
> On inspection the patches seem fine.
>
> Let's commit this and keep working on the pg_upgrade and test issues.

I have committed this in chunks over the last couple of days. It's done
now.

I didn't commit the initdb auto-detection patch. As I mentioned
earlier, that one is probably not necessary.

Btw., the default AppVeyor images are too old to support this. You need
something like 'image: Visual Studio 2019' to get a new enough image.
So that's one way to test what happens when it's not supported at run
time. (I did test it and you get a sensible error message.)

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services