Re: sync_standbys_defined read/write race on startup
Maksim.Melnikov <m.melnikov@postgrespro.ru>
From: "Maksim.Melnikov" <m.melnikov@postgrespro.ru>
To: Michael Paquier <michael@paquier.xyz>
Cc: Kirill Reshke <reshkekirill@gmail.com>,
PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2025-04-09T15:21:50Z
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
Attachments
- v4-0001-Fix-sync_standbys_defined-race-on-startup.patch (text/x-patch) patch v4-0001
Hi Michael, thanks for your answer. Test 041_checkpoint_at_promote.pl is really good example of using injection points, but anyway, I still don't see how injection points can help us here. In failed test case we started postgres, immediately open psql connection and commit prepared transaction. Postgres, on start, before accepting connections, fork checkpointer and checkpointer initialize shared parameter sync_standbys_defined in CheckpointerMain, before process loop. So, in most attempts, we can't call injection_points_attach in psql before macro INJECTION_POINT() code will be executed in checkpointer(I mean INJECTION_POINT() code instead sleep()), bacause checkpointer process is forking before database system is ready to accept connections. The manual execution of checkpoint can't help us too. P.S. sorry for style errors, I am new in postgres, so can miss some rules. Anyway, to avoid any community rules mistakes, attached patch with correct naming. Thanks. Best regards, Maksim Melnikov