On Thu, 26 Oct 2023, 00:10 Jelte Fennema, <postg...@jeltef.nl> wrote:

> On Wed, 25 Oct 2023 at 18:54, Daniele Varrazzo
> <daniele.varra...@gmail.com> wrote:
> > - connect_timeout
> > - multiple host, hostaddr, port
> > - load_balance_hosts=random
> >
> > Does this list sound complete?
>
> I think you'd also want to resolve the hostnames to IPs yourself and
> iterate over those one-by-one. Otherwise if the first IP returned for
> the hostname times out, you will never connect to the others.
>

For async connections we were already unpacking and processing the hosts
list, in order to perform non-blocking resolution and populate the
hostaddr. This already accounted for the possibility of one host resolving
to more than one address. But then we would have packed everything back
into a single conninfo and made a single connection attempt.

https://github.com/psycopg/psycopg/blob/14740add6bb1aebf593a65245df21699daabfad5/psycopg/psycopg/conninfo.py#L278

The goal here was only non-blocking name resolution. Ahaini understand we
should do is to split on the hosts for sync connections too, shuffle if
requested, and make separate  connection attempts.

-- Daniele

>

Reply via email to