Re: Multiple hosts in connection string failed to failover in non-hot standby mode
Justin Pryzby <pryzby@telsasoft.com>
From: Justin Pryzby <pryzby@telsasoft.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Hubert Zhang <zhubert@vmware.com>, tsunakawa.takay@fujitsu.com, pgsql-hackers@postgresql.org, Andreas Seltenreich <seltenreich@gmx.de>, Bruce Momjian <bruce@momjian.us>
Date: 2021-05-31T01:25:00Z
Lists: pgsql-hackers
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
Commits
-
Clear conn->errorMessage at successful completion of PQconnectdb().
- 896a0c44f93b 14.0 landed
- 138531f1bbc3 15.0 landed
-
Avoid ECPG test failures in some GSS-capable environments.
- 9bb5eecce645 14.0 landed
-
Try next host after a "cannot connect now" failure.
- c1d589571c49 14.0 landed
-
Uniformly identify the target host in libpq connection failure reports.
- 52a10224e3cc 14.0 landed
-
Allow pg_regress.c wrappers to postprocess test result files.
- 800d93f314b0 14.0 landed
-
In libpq, always append new error messages to conn->errorMessage.
- ffa2e4670123 14.0 landed