Re: [EXTERNAL] Re: Support load balancing in libpq

From: Jelte Fennema <postgres(at)jeltef(dot)nl>
To: Jacob Champion <jchampion(at)timescale(dot)com>
Cc: Maxim Orlov <orlovmg(at)gmail(dot)com>, Jelte Fennema <Jelte(dot)Fennema(at)microsoft(dot)com>, Michael Banck <mbanck(at)gmx(dot)net>, Aleksander Alekseev <aleksander(at)timescale(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [EXTERNAL] Re: Support load balancing in libpq
Date: 2023-01-13 17:10:23
Message-ID: CAGECzQRvSx58PcSGae1A8rOm6xiB94vf6cH3xs0TWJgvJpY-nw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Just a quick single-issue review, but I agree with Maxim that having
> one PRNG, seeded once, would be simpler

I don't agree that it's simpler. Because now there's a mutex you have
to manage, and honestly cross-platform threading in C is not simple.
However, I attached two additional patches that implement this
approach on top of the previous patchset. Just to make sure that
this patch is not blocked on this.

> with the tangible benefit that it would eliminate weird behavior on
> simultaneous connections when the client isn't using OpenSSL.

This is true, but still I think in practice very few people have a libpq
that's compiled without OpenSSL support.

> I'm guessing a simple lock on a
> global PRNG would be less overhead than the per-connection
> strong_random machinery, too, but I have no data to back that up.

It might very well have less overhead, but neither of them should take
up any significant amount of time during connection establishment.

> The test seed could then be handled globally as well (envvar?) so that you
> don't have to introduce a debug-only option into the connection string.

Why is a debug-only envvar any better than a debug-only connection option?
For now I kept the connection option approach, since to me they seem pretty
much equivalent.

Attachment Content-Type Size
v7-0003-Make-mutexes-easier-to-use-in-libpq.patch application/x-patch 5.9 KB
v7-0001-libpq-Run-pgindent-after-a9e9a9f32b3.patch application/x-patch 39.4 KB
v7-0004-Share-prng-state-between-all-PGconns-in-process.patch application/x-patch 3.9 KB
v7-0002-Support-load-balancing-in-libpq.patch application/x-patch 28.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2023-01-13 17:54:54 Re: No Callbacks on FATAL
Previous Message Nikolay Samokhvalov 2023-01-13 16:03:00 Re: Transaction timeout