Re: [EXTERNAL] Support load balancing in libpq

Jelte Fennema-Nio <postgres@jeltef.nl>

From: Jelte Fennema <postgres@jeltef.nl>
To: Daniel Gustafsson <daniel@yesql.se>
Cc: Tatsuo Ishii <ishii@sraoss.co.jp>, "Gregory Stark (as CFM)" <stark.cfm@gmail.com>, Andrey Borodin <amborodin86@gmail.com>, Jacob Champion <jchampion@timescale.com>, Maxim Orlov <orlovmg@gmail.com>, Jelte Fennema <Jelte.Fennema@microsoft.com>, mbanck@gmx.net, aleksander@timescale.com, PostgreSQL Hackers <pgsql-hackers@postgresql.org>, andres@anarazel.de
Date: 2023-03-28T07:33:27Z
Lists: pgsql-hackers
I think it's fine to remove it. It originated from postmaster.c, where
I copied the original implementation of libpq_prng_init from.

On Tue, 28 Mar 2023 at 09:22, Daniel Gustafsson <daniel@yesql.se> wrote:
>
> > On 28 Mar 2023, at 09:16, Tatsuo Ishii <ishii@sraoss.co.jp> wrote:
>
> > "unlikely" macro is used in libpq_prng_init() in the patch. I wonder
> > if the place is really 'hot' to use "unlikely" macro.
>
> I don't think it is, I was thinking to rewrite as the below sketch:
>
> {
>     if (pg_prng_strong_seed(&conn->prng_state)))
>         return;
>
>     /* fallback seeding */
> }
>
> --
> Daniel Gustafsson
>



Commits

  1. Fix pointer cast for seed calculation on 32-bit systems

  2. Copy and store addrinfo in libpq-owned private memory

  3. libpq: Use modern socket flags, if available.