pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Subject: Re: strange error reporting
Date: Mon, 03 May 2021 10:47:47 -0400
Message-ID: <3792030.1620053267@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+TgmobKLcKnpNBkwzGsCc9WQKS9dk_=CckR2feabtOB1KE-kw@mail.gmail.com>
References: <CA+TgmobssJ6rS22dspWnu-oDxXevGmhMD8VcRBjmj-b9UDqRjw@mail.gmail.com>
	<717401.1611163169@sss.pgh.pa.us>
	<CA+Tgmoas37XHT48KjEb0zACCTxSTkba_VP-BDQAft-Mj5_5z_Q@mail.gmail.com>
	<718535.1611164867@sss.pgh.pa.us>
	<CA+Tgmobcfsh9jVdgiF+cUwtmbrdiLE8F9mt7a2J4yyO-ix1G1A@mail.gmail.com>
	<798280.1611192827@sss.pgh.pa.us>
	<0621c8e2-6b87-219d-2eaf-ae1a2cb822b2@enterprisedb.com>
	<CA+TgmobKLcKnpNBkwzGsCc9WQKS9dk_=CckR2feabtOB1KE-kw@mail.gmail.com>

Robert Haas <robertmhaas@gmail.com> writes:
> On Mon, May 3, 2021 at 6:08 AM Peter Eisentraut
> <peter.eisentraut@enterprisedb.com> wrote:
>> Throwing the socket address in there seems a bit distracting and
>> misleading, and it also pushes off the actual information very far to
>> the end.  (Also, in some cases the socket path is very long, making the
>> actual information even harder to find.)  By the time you get to this
>> error, you have already connected, so mentioning the server address
>> seems secondary at best.

> It feels a little counterintuitive to me too but I am nevertheless
> inclined to believe that it's an improvement. When multi-host
> connection strings are used, the server address may not be clear. In
> fact, even when they're not, it may not be clear to a new user that
> socket communication is used, and it may not be clear where the socket
> is located.

Yeah.  The specific problem I'm concerned about solving here is
"I wasn't connecting to the server I thought I was", which could be
a contributing factor in almost any connection-time failure.  The
multi-host-connection-string feature made that issue noticeably worse,
but surely we've all seen trouble reports that boiled down to that
even before that feature came in.

As you say, we could perhaps redesign the messages to provide this
info in another order.  But it'd be difficult, and I think it might
come out even more confusing in cases where libpq tried several
servers on the way to finally failing.  The old code's error
reporting for such cases completely sucked, whereas now you get
a reasonably complete trace of the attempts.  As a quick example,
for a case of bad hostname followed by wrong port:

$ psql -d "host=foo1,sss2 port=5432,5342"
psql: error: could not translate host name "foo1" to address: Name or service not known
connection to server at "sss2" (192.168.1.48), port 5342 failed: Connection refused
        Is the server running on that host and accepting TCP/IP connections?

v13 renders this as

$ psql -d "host=foo1,sss2 port=5432,5342"
psql: error: could not translate host name "foo1" to address: Name or service not known
could not connect to server: Connection refused
        Is the server running on host "sss2" (192.168.1.48) and accepting
        TCP/IP connections on port 5342?

Now, of course the big problem there is the lack of consistency about
how the two errors are laid out; but I'd argue that putting the
server identity info first is better than putting it later.

Also, if you experiment with other cases such as some of the servers
complaining about wrong user name, the old behavior is even harder
to follow about which server said what.

			regards, tom lane





view thread (18+ messages)

Message-ID: <3792030.1620053267@sss.pgh.pa.us>
Permalink:  ../3792030.1620053267@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3792030.1620053267@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, robertmhaas@gmail.com, peter.eisentraut@enterprisedb.com
  Subject: Re: strange error reporting
  In-Reply-To: <3792030.1620053267@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox