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

Hubert Zhang <zhubert@vmware.com>

From: Hubert Zhang <zhubert@vmware.com>
To: "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2020-10-27T07:14:14Z
Lists: pgsql-hackers
Hi hackers,

Libpq has supported to specify multiple hosts in connection string and enable auto failover when the previous PostgreSQL instance cannot be accessed.
But when I tried to enable this feature for a non-hot standby, it cannot do the failover with the following messages.

psql: error: could not connect to server: FATAL:  the database system is starting up

Document says ' If a connection is established successfully, but authentication fails, the remaining hosts in the list are not tried.'
I'm wondering is it a feature by design or a bug? If it's a bug, I plan to fix it.

Thanks,
Hubert Zhang

Commits

  1. Clear conn->errorMessage at successful completion of PQconnectdb().

  2. Avoid ECPG test failures in some GSS-capable environments.

  3. Try next host after a "cannot connect now" failure.

  4. Uniformly identify the target host in libpq connection failure reports.

  5. Allow pg_regress.c wrappers to postprocess test result files.

  6. In libpq, always append new error messages to conn->errorMessage.