[bug fix] PG10: libpq doesn't connect to alternative hosts when some errors occur

From: "Tsunakawa, Takayuki" <tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: [bug fix] PG10: libpq doesn't connect to alternative hosts when some errors occur
Date: 2017-05-12 04:28:50
Message-ID: 0A3221C70F24FB45833433255569204D1F6F5659@G01JPEXMBYT05
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

I found a problem with libpq connection failover. When libpq cannot connect to earlier hosts in the host list, it doesn't try to connect to other hosts. For example, when you specify a wrong port that some non-postgres program is using, or some non-postgres program is using PG's port unexpectedly, you get an error like this:

$ psql -h localhost -p 23
psql: received invalid response to SSL negotiation: 
$ psql -h localhost -p 23 -d "sslmode=disable"
psql: expected authentication request from server, but received 

Likewise, when the first host has already reached max_connections, libpq doesn't attempt the connection aginst later hosts.

The attached patch fixes this. I'll add this item in the PostgreSQL 10 Open Items.

Regards
Takayuki Tsunakawa

Attachment Content-Type Size
libpq-reconnect-on-error.patch application/octet-stream 2.3 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2017-05-12 04:30:25 Improvement in log message of logical replication worker
Previous Message Jeff Davis 2017-05-12 04:08:29 Hash Functions