From: Justin Pryzby <pryzby@telsasoft.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
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: Sun, 30 May 2021 20:25:00 -0500
Message-ID: <20210531012500.GP2082@telsasoft.com> (raw)
In-Reply-To: <4170264.1620321747@sss.pgh.pa.us>
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>
On Thu, May 06, 2021 at 01:22:27PM -0400, Tom Lane wrote:
> Justin Pryzby <pryzby@telsasoft.com> writes:
> > 52a10224 broke sqlsmith, of all things.
>
> > It was using errmsg as a test of success, instead of checking if the connection
> > result wasn't null:
>
> > conn = PQconnectdb(conninfo.c_str());
> > char *errmsg = PQerrorMessage(conn);
> > if (strlen(errmsg))
> > throw dut::broken(errmsg, "08001");
>
> > That's clearly the wrong thing to do, but maybe this should be described in the
> > release notes as a compatibility issue, in case other people had the same idea.
> > Clearing errorMessage during success is an option..
>
> Hm. I'd debated whether to clear conn->errorMessage at the end of
> a successful connection sequence, and decided not to on the grounds
> that it might be interesting info (eg it could tell you why you
> ended up connected to server Y and not server X). But perhaps
> it's too much of a compatibility break for this small benefit.
I don't care if applications break because they check the errorMessage instead
of the return value...
..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.
--
Justin
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: pryzby@telsasoft.com, tgl@sss.pgh.pa.us, 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: <20210531012500.GP2082@telsasoft.com>
* 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