From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Paquier <michael@paquier.xyz>
Cc: Justin Pryzby <pryzby@telsasoft.com>
Cc: Hubert Zhang <zhubert@vmware.com>
Cc: tsunakawa.takay@fujitsu.com, pgsql-hackers@postgresql.org, Andreas Seltenreich <seltenreich@gmx.de>
Cc: Bruce Momjian <bruce@momjian.us>
Subject: Re: Multiple hosts in connection string failed to failover in non-hot standby mode
Date: Mon, 13 Sep 2021 16:09:26 -0400
Message-ID: <504834.1631563766@sss.pgh.pa.us> (raw)
In-Reply-To: <YLRDV0MqQnGRIo4c@paquier.xyz>
References: <BN6PR05MB3492948E4FD76C156E747E8BC9160@BN6PR05MB3492.namprd05.prod.outlook.com>
<TYAPR01MB299012CAC510D2644AEC2246FE160@TYAPR01MB2990.jpnprd01.prod.outlook.com>
<BN6PR05MB3492DFB2FF32B771172CC2F2C9170@BN6PR05MB3492.namprd05.prod.outlook.com>
<229507.1610056206@sss.pgh.pa.us>
<770711.1610318330@sss.pgh.pa.us>
<20210506162651.GJ27406@telsasoft.com>
<4170264.1620321747@sss.pgh.pa.us>
<20210531012500.GP2082@telsasoft.com>
<YLRDV0MqQnGRIo4c@paquier.xyz>
Michael Paquier <michael@paquier.xyz> writes:
> On Sun, May 30, 2021 at 08:25:00PM -0500, Justin Pryzby wrote:
>> ..But I think it's not useful to put details into errorMessage on success,
>> unless you're going to document that. It would never have occurred to me to
>> look there, or that it would even be safe.
> Yeah. On the contrary, it could be confusing if one sees an error
> message but there is nothing to worry about, because things are
> working in the scope of what the user wanted at connection time.
I got around to looking at this issue today, and verified that only one
place needs to be changed, as attached.
Although I was initially thinking that maybe we should leave the code
as-is, I now agree that resetting errorMessage is a good idea, because
what tends to be in it at this point is something like
"connection to server on socket "/tmp/.s.PGSQL.5432" failed: "
(ie the string made by emitHostIdentityInfo). Anybody who does
look at that is likely to be confused, because the connection
*didn't* fail.
There might be some value in my original idea of preserving a trace of
the servers we tried before succeeding. But it would take additional
work to present it in a non-confusing way, and given the lack of any
field requests for that, I'm not excited about doing it right now.
(One could also argue that it ought to get tied into the PQtrace
facilities somehow, rather than being done in this ad-hoc way.)
regards, tom lane
Attachments:clear-errorMessage-upon-successful-connection.patch (text/x-diff, 693B) downloaddiff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.cindex 49eec3e835..b288d346f9 100644--- a/src/interfaces/libpq/fe-connect.c+++ b/src/interfaces/libpq/fe-connect.c@@ -3654,6 +3654,13 @@ keep_going: /* We will come back to here until there is
/* We can release the address list now. */
release_conn_addrinfo(conn);
+ /*+ * Contents of conn->errorMessage are no longer interesting+ * (and it seems some clients expect it to be empty after a+ * successful connection).+ */+ resetPQExpBuffer(&conn->errorMessage);+
/* We are open for business! */
conn->status = CONNECTION_OK;
return PGRES_POLLING_OK;
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, michael@paquier.xyz, pryzby@telsasoft.com, zhubert@vmware.com, seltenreich@gmx.de, bruce@momjian.us
Subject: Re: Multiple hosts in connection string failed to failover in non-hot standby mode
In-Reply-To: <504834.1631563766@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