Make pg_regress print a connstring with sockdir

Started by Craig Ringerabout 9 years ago9 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

won't retrysuccessCI history

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t37312
psql -h localhost -U postgres

Built from patchset v3 (message #3), July 27, 2026 at 10:35 PM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t37312_3 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t37312_3 && git checkout t37312_3

Patchset v3 (message #3) is on t37312_3

Jump to latest
#1Craig Ringer
craig@2ndquadrant.com

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+3-3
#2Michael Paquier
michael@paquier.xyz
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)
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:

t37312_3
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+4-3
#4Michael Paquier
michael@paquier.xyz
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