Re: libpq async connection and multiple hosts

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: Jelte Fennema <postgres(at)jeltef(dot)nl>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: libpq async connection and multiple hosts
Date: 2023-10-26 01:31:33
Message-ID: CA+mi_8bOcddzUTiLrLQD8ZXvRRnaNU1Z9iOSJCcrRuyYTWGOHw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 26 Oct 2023, 00:10 Jelte Fennema, <postgres(at)jeltef(dot)nl> wrote:

> On Wed, 25 Oct 2023 at 18:54, Daniele Varrazzo
> <daniele(dot)varrazzo(at)gmail(dot)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

>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2023-10-26 01:57:10 Re: Document aggregate functions better w.r.t. ORDER BY
Previous Message Tom Lane 2023-10-26 00:49:49 Re: Should we represent temp files as unsigned long int instead of signed long int type?