Re: sync_standbys_defined read/write race on startup
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: "Maksim.Melnikov" <m.melnikov@postgrespro.ru>
Cc: Kirill Reshke <reshkekirill@gmail.com>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2025-04-09T07:45:57Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix race with synchronous_standby_names at startup
- e2f42f812a80 13.21 landed
- 873aff945a7b 14.18 landed
- ec59500a1740 15.13 landed
- c922ae2c42a6 16.9 landed
- 3339847ccde0 17.5 landed
- 2e57790836c6 18.0 landed
On Mon, Apr 07, 2025 at 11:39:23PM +0300, Maksim.Melnikov wrote:
> Hi everyone, thanks for your comments.
> I've just wanted to share little cosmetic
> fixes for previous patch.
Note: I would suggest to use a version number for the patches, rather
than a 0003 which usually implies that this is third patch in a
series. So I would use a command like that when generating a v4 of
this single patch:
git format-patch -1 -v4
`git am` is OK with what you have sent, but it's just a bit confusing.
Anyway, back to the patch..
I am still playing with the patch and will most probably send an
update tomorrow, but the injection point technique should be rather
straight-forward. You have done most of the work by finding a
problematic case in 009_twophase.pl, so I would suggest the following:
- Instead of the sleep(), add a macro INJECTION_POINT() with a new
name.
- Then implement a TAP test that reproduces the failure by adding a
"wait" point, combined with a "wakeup", probably with a BackgroundPsql
object to keep the problematic SQL sequence alive while it waits.
I would suggest to look at what we do with create-restart-point in the
recovery test 041_checkpoint_at_promote.pl as a starting point. For
background sessions, also look at 007_catcache_inval.pl in test_misc.
The new test may be better in 009_twophase.pl, conditional depending
on the existence of the extension "injection_points". You can check
how it is done in the other TAP tests; these rely on check_extension()
and $ENV{enable_injection_points}.
--
Michael