injection_points: Switch wait/wakeup to rely on atomics This change switches the implementation of wait and wakeups in the module injection_points to not rely anymore on condition variables, using a more primitive implementation based on atomics. The former implementation required a PGPROC, making it impossible to inject waits in the postmaster or during authentication. A couple of use cases have popped up for these in the past, where this would have become handy.
The loop in the wait callback that relied on a condition variable is replaced by an atomic counter, whose check increases over time in an exponential manner (starts at 10us for quick responsiveness, up to 100ms). This change may be backpatched at some point depending on how much testing coverage is wanted. Let's limit ourselves to HEAD for now, checking things first with the buildfarm. Creating a wait still requires the SQL interface. We are looking at expanding that with an alternative implementation, so as early startup or authentication waits would become possible. This refactoring piece is mandatory to achieve this goal. Reviewed-by: Andrey Borodin <[email protected]> Discussion: https://postgr.es/m/[email protected] Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/8daeaa9b642c3c23cbc516da80d50aade6f4dc07 Modified Files -------------- .../modules/injection_points/injection_points.c | 56 +++++++++++----------- 1 file changed, 29 insertions(+), 27 deletions(-)
