Re: Multiple hosts in connection string failed to failover in non-hot standby mode

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Hubert Zhang <zhubert(at)vmware(dot)com>, tsunakawa(dot)takay(at)fujitsu(dot)com, pgsql-hackers(at)postgresql(dot)org, Andreas Seltenreich <seltenreich(at)gmx(dot)de>, Bruce Momjian <bruce(at)momjian(dot)us>
Subject: Re: Multiple hosts in connection string failed to failover in non-hot standby mode
Date: 2021-05-31 01:25:00
Message-ID: 20210531012500.GP2082@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, May 06, 2021 at 01:22:27PM -0400, Tom Lane wrote:
> Justin Pryzby <pryzby(at)telsasoft(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2021-05-31 01:30:08 Re: Teaching users how they can get the most out of HOT in Postgres 14
Previous Message Michael Paquier 2021-05-31 00:14:36 Re: be-secure-gssapi.c and auth.c with setenv() not compatible on Windows