Injection points: some tools to wait and wake
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Postgres hackers <pgsql-hackers@lists.postgresql.org>
Cc: Ashutosh Bapat <ashutosh.bapat@gmail.com>
Date: 2024-02-19T06:01:40Z
Lists: pgsql-hackers
Attachments
- 0001-injection_points-Add-routines-to-wait-and-wake-proce.patch (text/x-diff) patch 0001
- 0002-Add-regression-test-for-restart-points-during-promot.patch (text/x-diff) patch 0002
Hi all, (Ashutosh in CC as he was involved in the discussion last time.) I have proposed on the original thread related to injection points to have more stuff to be able to wait at an arbtrary point and wake at will the process waiting so as it is possible to control the order of actions taken in a test: https://www.postgresql.org/message-id/ZTiV8tn_MIb_H2rE%40paquier.xyz I didn't do that in the other thread out of time, but here is a patch set to complete what I wanted, using a condition variable to wait and wake processes: - State is in shared memory, using a DSM tracked by the registry and an integer counter. - Callback to wait on a condition variable. - SQL function to update the shared state and broadcast the update to the condition variable. - Use a custom wait event to track the wait in pg_stat_activity. 0001 requires no backend changes, only more stuff into the test module injection_points so that could be backpatched assuming that the backend is able to support injection points. This could be expanded into using more variables and/or states, but I don't really see a point in introducing more without a reason to do so, and I have no need for more at the moment. 0002 is a polished version of the TAP test that makes use of this facility, providing coverage for the bug fixed by 7863ee4def65 (reverting this commit causes the test to fail), where a restart point runs across a promotion request. The trick is to stop the checkpointer in the middle of a restart point and issue a promotion in-between. Thoughts and comments are welcome. -- Michael
Commits
-
Add PostgreSQL::Test::Cluster::wait_for_event()
- eca2c1ea85eb 17.0 landed
-
Add regression test for restart points during promotion
- 6782709df81f 17.0 landed
-
injection_points: Add wait and wakeup of processes
- 37b369dc67bc 17.0 landed