Re: injection_points: Switch wait/wakeup to use atomics rather than latches - Mailing list pgsql-hackers

From Andrey Borodin
Subject Re: injection_points: Switch wait/wakeup to use atomics rather than latches
Date
Msg-id E2ED96F8-F2A4-4FC0-A3F3-FF878F40EDCE@yandex-team.ru
Whole thread
In response to Re: injection_points: Switch wait/wakeup to use atomics rather than latches  (Heikki Linnakangas <hlinnaka@iki.fi>)
List pgsql-hackers

> On 8 Jul 2026, at 12:17, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
>
> dead-end backends, max_connections, reserved_connections and all that

Hi Heikki, Michael,

Thanks for pushing the atomics patch.  Following Heikki's pointer to
waits before authentication and the connection-limit area, here is where
I looked:

- 002_connection_limits.pl did not seem to need a blocking wait, closer to the
  WARNING/LOG point (as discussed on the postmaster-cleanup thread [0]).

- 007_pre_auth.pl already attaches init-pre-auth, but it exists to test
  pg_stat_activity itself, and its old race (matching state='starting'
  before the backend reached the point) is already fixed by querying
  wait_event.  So converting it buys little, as you noted.

- So PFA a new test: a connection counts against max_connections
  from InitProcessPhase2(), before authentication.  I added a TAP test
  that fills every slot with pre-auth backends and checks that one more
  connection is refused with "too many clients".  Such backends can't be
  identified over SQL and there is no free slot for a monitoring session,
  so the test finds them through the filesystem markers. If this test
  direction seems viable - I'll polish the test.

Is this enough to justify the filesystem layer, or would you rather see
more cases?  Heikki, if you have a specific dead-end-backend /
reserved-connection scenario in mind, I'm happy to aim the test there.

It would be slightly better to have an unfixed bug to close with such
test.  But I do not have a spare one, so of course we could introduce a
new bug. But that clearly deserves its own thread.

Thanks!


Best regards, Andrey Borodin.

[0] https://postgr.es/m/ggflhkciwdyotpoie323chu2c2idpjk5qimrn462encwx2io7s@thmcxl7i6dpw

Attachment

pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: libpq: Process buffered SSL read bytes to support records >8kB on async API
Next
From: Jeff Davis
Date:
Subject: Re: Bug in ALTER SUBSCRIPTION ... SERVER / ... CONNECTION with broken old server