Re: libpq async connection and multiple hosts

2023-10-26 Thread Jelte Fennema
On Thu, 26 Oct 2023 at 03:31, Daniele Varrazzo wrote: > 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. If you pack the resolved addresses in

Re: libpq async connection and multiple hosts

2023-10-25 Thread Daniele Varrazzo
On Thu, 26 Oct 2023, 00:10 Jelte Fennema, wrote: > On Wed, 25 Oct 2023 at 18:54, Daniele Varrazzo > 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

Re: libpq async connection and multiple hosts

2023-10-25 Thread Jelte Fennema
On Wed, 25 Oct 2023 at 18:54, Daniele Varrazzo 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 I

Re: libpq async connection and multiple hosts

2023-10-25 Thread Daniele Varrazzo
On Wed, 25 Oct 2023 at 17:35, Jelte Fennema wrote: > Another approach is to use tcp_user_timeout instead of connect_timeout > to skip non-responsive hosts. It's not completely equivalent though to > connection_timeout though, since it also applies when the connection > is actually being used. Als

Re: libpq async connection and multiple hosts

2023-10-25 Thread Daniele Varrazzo
On Wed, 25 Oct 2023 at 17:35, Jelte Fennema wrote: > You should implement load_balance_hosts=random though > by randomizing your hosts list. Good catch. So it seems that, if someone wants to build an equivalent an async version of PQconnectdb, they need to handle on their own: - connect_timeout

Re: libpq async connection and multiple hosts

2023-10-25 Thread Jelte Fennema
On Wed, 25 Oct 2023 at 17:03, Daniele Varrazzo wrote: > However, ISTM that connecting to multiple hosts is not supported > either. I have a couple of issues I am looking into in psycopg 3: > > - https://github.com/psycopg/psycopg/issues/602 > - https://github.com/psycopg/psycopg/issues/674 Anothe

libpq async connection and multiple hosts

2023-10-25 Thread Daniele Varrazzo
Hello, We are aware that, using async connection functions (`PQconnectStart`, `PQconnectPoll`), the `connect_timeout` parameter is not supported; this is documented at https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PQCONNECTSTARTPARAMS """ The connect_timeout connection paramete