Try next host after a "cannot connect now" failure.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 11 Jan 2021 19:12:31 +0000 (14:12 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 11 Jan 2021 19:12:31 +0000 (14:12 -0500)
commitc1d589571c497a952d7fbe40d9828655859d746f
tree4cb59beae2e500fba40bf1115fca2a3864cd034d
parent52a10224e3cc1d706ba9800695f97cb163b747d5
Try next host after a "cannot connect now" failure.

If a server returns ERRCODE_CANNOT_CONNECT_NOW, try the next host,
if multiple host names have been provided.  This allows dealing
gracefully with standby servers that might not be in hot standby mode
yet.

In the wake of the preceding commit, it might be plausible to retry
many more error cases than we do now, but I (tgl) am hesitant to
move too aggressively on that --- it's not clear it'd be desirable
for cases such as bad-password, for example.  But this case seems
safe enough.

Hubert Zhang, reviewed by Takayuki Tsunakawa

Discussion: https://postgr.es/m/BN6PR05MB3492948E4FD76C156E747E8BC9160@BN6PR05MB3492.namprd05.prod.outlook.com
src/interfaces/libpq/fe-connect.c