Thread: [HACKERS] Make pg_regress print a connstring with sockdir

[HACKERS] Make pg_regress print a connstring with sockdir

From
Craig Ringer
Date:
Hi all

It's a pain having to find the postmaster command line to get the port pg_regress started a server on. We print the port in the pg_regress output, why not the socket directory / host?

How about

running on 'port=50848 host=/tmp/pg_regress-UMrcT3' with PID 16409

per the attached?

If you'd prefer nicer wording at the expense of two lines, maybe

running with PID 16409
connection string: 'port=50848 host=/tmp/blah'

--
 Craig Ringer                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services
Attachment

Re: [HACKERS] Make pg_regress print a connstring with sockdir

From
Michael Paquier
Date:
On Mon, Aug 28, 2017 at 2:28 PM, Craig Ringer <craig@2ndquadrant.com> wrote:
> It's a pain having to find the postmaster command line to get the port
> pg_regress started a server on. We print the port in the pg_regress output,
> why not the socket directory / host?
>
> How about
> running on 'port=50848 host=/tmp/pg_regress-UMrcT3' with PID 16409
>
> per the attached?
>
> If you'd prefer nicer wording at the expense of two lines, maybe
>
> running with PID 16409
> connection string: 'port=50848 host=/tmp/blah'

Yeah, I think that this is a good idea.
-- 
Michael



Re: [HACKERS] Make pg_regress print a connstring with sockdir

From
Craig Ringer
Date:
============== starting postmaster                    ==============
running with PID 30235; connect with:
  psql "host='/tmp/pg_regress-j74yFE' port=50848 dbname='regression'"
============== creating database "regression"         ==============


On 28 August 2017 at 14:08, Michael Paquier <michael.paquier@gmail.com> wrote:
On Mon, Aug 28, 2017 at 2:28 PM, Craig Ringer <craig@2ndquadrant.com> wrote:
> It's a pain having to find the postmaster command line to get the port
> pg_regress started a server on. We print the port in the pg_regress output,
> why not the socket directory / host?
>
> How about
> running on 'port=50848 host=/tmp/pg_regress-UMrcT3' with PID 16409
>
> per the attached?
>
> If you'd prefer nicer wording at the expense of two lines, maybe
>
> running with PID 16409
> connection string: 'port=50848 host=/tmp/blah'

Yeah, I think that this is a good idea.
--
Michael



--
 Craig Ringer                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services
Attachment

Re: [HACKERS] Make pg_regress print a connstring with sockdir

From
Michael Paquier
Date:
On Mon, Aug 28, 2017 at 4:07 PM, Craig Ringer <craig@2ndquadrant.com> wrote:
> ============== starting postmaster                    ==============
> running with PID 30235; connect with:
>   psql "host='/tmp/pg_regress-j74yFE' port=50848 dbname='regression'"
> ============== creating database "regression"         ==============

Sorry if my words were confusing and have cost you three minutes of
development. I like better the one-line version :)
Now a socket path could be quite long. I can live with that personally.
-- 
Michael



Re: [HACKERS] Make pg_regress print a connstring with sockdir

From
Craig Ringer
Date:

On 28 August 2017 at 15:19, Michael Paquier <michael.paquier@gmail.com> wrote:
On Mon, Aug 28, 2017 at 4:07 PM, Craig Ringer <craig@2ndquadrant.com> wrote:
> ============== starting postmaster                    ==============
> running with PID 30235; connect with:
>   psql "host='/tmp/pg_regress-j74yFE' port=50848 dbname='regression'"
> ============== creating database "regression"         ==============

Sorry if my words were confusing and have cost you three minutes of
development. I like better the one-line version :)
Now a socket path could be quite long. I can live with that personally.

I'm not fussed, I just think we should show it one way or the other.

One nice thing about the two line form is that you can double-click/middle-click to open a new psql in the pg_regress session pretty much instantly.
 



--
 Craig Ringer                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

Re: [HACKERS] Make pg_regress print a connstring with sockdir

From
Alvaro Herrera
Date:
Craig Ringer wrote:
> On 28 August 2017 at 15:19, Michael Paquier <michael.paquier@gmail.com>
> wrote:
> 
> > On Mon, Aug 28, 2017 at 4:07 PM, Craig Ringer <craig@2ndquadrant.com>
> > wrote:
> > > ============== starting postmaster                    ==============
> > > running with PID 30235; connect with:
> > >   psql "host='/tmp/pg_regress-j74yFE' port=50848 dbname='regression'"
> > > ============== creating database "regression"         ==============
> >
> > Sorry if my words were confusing and have cost you three minutes of
> > development. I like better the one-line version :)
> > Now a socket path could be quite long. I can live with that personally.
> >
> 
> I'm not fussed, I just think we should show it one way or the other.
> 
> One nice thing about the two line form is that you can
> double-click/middle-click to open a new psql in the pg_regress session
> pretty much instantly.

So don't add gettext_noop() around it :-)

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



Re: [HACKERS] Make pg_regress print a connstring with sockdir

From
Tom Lane
Date:
Craig Ringer <craig@2ndquadrant.com> writes:
> It's a pain having to find the postmaster command line to get the port
> pg_regress started a server on. We print the port in the pg_regress output,
> why not the socket directory / host?

I'm not following the point here.  The test postmaster isn't really
going to be around long enough to connect to it manually.  If you
want to do that, you should be using "installcheck", and then the
problem doesn't arise.

The reason for printing the port number, if memory serves, is to
aid in debugging port selection conflicts.  That doesn't really
apply for temporary socket directories; we're expecting libc to
avoid any conflicts there.
        regards, tom lane



Re: [HACKERS] Make pg_regress print a connstring with sockdir

From
Craig Ringer
Date:

On 28 August 2017 at 19:45, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Craig Ringer <craig@2ndquadrant.com> writes:
> It's a pain having to find the postmaster command line to get the port
> pg_regress started a server on. We print the port in the pg_regress output,
> why not the socket directory / host?

I'm not following the point here.  The test postmaster isn't really
going to be around long enough to connect to it manually.  If you
want to do that, you should be using "installcheck", and then the
problem doesn't arise.

The reason for printing the port number, if memory serves, is to
aid in debugging port selection conflicts.  That doesn't really
apply for temporary socket directories; we're expecting libc to
avoid any conflicts there.

I'm frequently debugging postmasters that are around long enough. Deadlocks, etc.

It's also way easier to debug shmem related issues with a live postmaster vs a core.

--
 Craig Ringer                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

Re: [HACKERS] Make pg_regress print a connstring with sockdir

From
Robert Haas
Date:
On Mon, Aug 28, 2017 at 7:57 AM, Craig Ringer <craig@2ndquadrant.com> wrote:
> I'm frequently debugging postmasters that are around long enough. Deadlocks,
> etc.
>
> It's also way easier to debug shmem related issues with a live postmaster vs
> a core.

Yeah.  I don't *frequently* debug postmasters that hang during the
regression tests, but I definitely have done it, and I think something
like this would make it easier.  Right now if something wedges and you
need to connect to the postmaster to see what's going on, you have to
grep for the pid, then lsof to get the socket directory.  This would
simplify things.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company