Incremental Update: New Discussion on Wait Point Detection Without PGPROC
The thread has advanced with a focused sub-discussion on how to detect that a wait point has been reached when there is no PGPROC (and thus no pg_stat_activity wait event visibility). This is a practical problem for writing reliable tests against the new atomic-based mechanism.
New Technical Proposal: mmap'd Shared State File
Andrey Borodin proposes a novel approach: memory-map inj_state to a fixed file (PGDATA/injection_points.shm). This would allow TAP test scripts to directly:
- Poll the
name[]array in the mapped file to detect that a backend has reached a wait point - Write to
wait_counts[]to wake the backend
This is architecturally different from Michael's earlier LOG-polling idea — it provides direct shared-memory access from the test harness rather than indirect observation through log output.
Michael's Response: Portability Concerns
Michael raises the WIN32 portability issue: mmap() is POSIX-only, and Windows requires CreateFileMapping()/MapViewOfFile(). He floats two possible directions:
- A generic interface that extensions could use for similar cross-process shared state exposure
- A portable abstraction layer added specifically within the injection_points module
This suggests the discussion is evolving toward a broader infrastructure question about how test tooling can observe/interact with server-internal shared memory from outside the server process.
Validation of the Core Patch
Borodin confirms the patch works for his postmaster-kill corruption testing scenario. His test methodology involves iteratively sending SIGKILL to cluster PIDs and waiting for shared memory release before attempting recovery — exactly the use case that motivated the latch-to-atomics switch.
Practical Testing Methodology Debate
The exchange about sleep(1) vs. reliable detection highlights a real buildfarm concern: hardcoded sleeps are both too slow for fast machines and unreliable on slow machines. Any solution must work across the full spectrum of buildfarm animals. This constrains the design space — LOG polling introduces I/O latency and parsing complexity, while mmap'd state offers low-latency direct observation but adds portability burden.