Make pg_regress print a connstring with sockdir

Started by Craig Ringerover 8 years ago9 messages
#1Craig Ringer
craig@2ndquadrant.com
1 attachment(s)

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

Attachments:

v1-0001-Show-sockdir-hostname-in-pg_regress-startup-outpu.patchtext/x-patch; charset=US-ASCII; name=v1-0001-Show-sockdir-hostname-in-pg_regress-startup-outpu.patchDownload
From 5b242d9af911a88c084a74bf49904b94117347c1 Mon Sep 17 00:00:00 2001
From: Craig Ringer <craig@2ndquadrant.com>
Date: Mon, 28 Aug 2017 13:28:05 +0800
Subject: [PATCH v1] Show sockdir/hostname in pg_regress startup output

---
 src/test/regress/pg_regress.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c
index abb742b..11931db 100644
--- a/src/test/regress/pg_regress.c
+++ b/src/test/regress/pg_regress.c
@@ -2438,8 +2438,9 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
 #else
 #define ULONGPID(x) (unsigned long) (x)
 #endif
-		printf(_("running on port %d with PID %lu\n"),
-			   port, ULONGPID(postmaster_pid));
+		printf(_("running on 'port=%d host=%s' with PID %lu\n"),
+			   port, hostname ? hostname : sockdir,
+ 			   ULONGPID(postmaster_pid));
 	}
 	else
 	{
-- 
2.9.5

#2Michael Paquier
michael.paquier@gmail.com
In reply to: Craig Ringer (#1)
Re: Make pg_regress print a connstring with sockdir

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

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

#3Craig Ringer
craig@2ndquadrant.com
In reply to: Michael Paquier (#2)
1 attachment(s)
Re: Make pg_regress print a connstring with sockdir

============== 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

Attachments:

v2-0001-Show-sockdir-hostname-in-pg_regress-startup-outpu.patchtext/x-patch; charset=US-ASCII; name=v2-0001-Show-sockdir-hostname-in-pg_regress-startup-outpu.patchDownload
From c3613d4526ba04fb18011e2af1923b9a167effec Mon Sep 17 00:00:00 2001
From: Craig Ringer <craig@2ndquadrant.com>
Date: Mon, 28 Aug 2017 13:28:05 +0800
Subject: [PATCH v2] Show sockdir/hostname in pg_regress startup output

---
 src/test/regress/pg_regress.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c
index abb742b..4cccefc 100644
--- a/src/test/regress/pg_regress.c
+++ b/src/test/regress/pg_regress.c
@@ -2438,8 +2438,10 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
 #else
 #define ULONGPID(x) (unsigned long) (x)
 #endif
-		printf(_("running on port %d with PID %lu\n"),
-			   port, ULONGPID(postmaster_pid));
+		printf(_("running with PID %lu; connect with:\n"),
+ 			   ULONGPID(postmaster_pid));
+		printf(gettext_noop("  psql \"host='%s' port=%d dbname='%s'\"\n"),
+			   hostname ? hostname : sockdir, port, dblist->str);
 	}
 	else
 	{
-- 
2.9.5

#4Michael Paquier
michael.paquier@gmail.com
In reply to: Craig Ringer (#3)
Re: Make pg_regress print a connstring with sockdir

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

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

#5Craig Ringer
craig@2ndquadrant.com
In reply to: Michael Paquier (#4)
Re: Make pg_regress print a connstring with sockdir

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

#6Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Craig Ringer (#5)
Re: Make pg_regress print a connstring with sockdir

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

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

#7Tom Lane
tgl@sss.pgh.pa.us
In reply to: Craig Ringer (#1)
Re: Make pg_regress print a connstring with sockdir

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

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

#8Craig Ringer
craig@2ndquadrant.com
In reply to: Tom Lane (#7)
Re: Make pg_regress print a connstring with sockdir

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

#9Robert Haas
robertmhaas@gmail.com
In reply to: Craig Ringer (#8)
Re: Make pg_regress print a connstring with sockdir

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

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