injection_points: Fix race condition with local injection point tests
commitf4083c49751018ae2140de8bf752b8d60485a6ca
authorMichael Paquier <michael@paquier.xyz>
Tue, 9 Apr 2024 01:31:12 +0000 (9 10:31 +0900)
committerMichael Paquier <michael@paquier.xyz>
Tue, 9 Apr 2024 01:31:12 +0000 (9 10:31 +0900)
treeb99f1e170e708fa9a900a55a4f8637a067434093
parentf463de59d90c10f3d0daf2d5b132ca58e4111a08
injection_points: Fix race condition with local injection point tests

The module relies on a shmem exit callback to clean up any injection
points linked to a specific process.  One of the tests checks for the
case of an injection point name reused in a second connection where the
first connection should clean it up, but it did not count for the fact
that the shmem exit callback of the first connection may not have run
when the second connection begins its work.

The regress library includes a wait_pid() that can be used for this
purpose, instead of a custom wait logic, so let's rely on it to wait for
the first connection to exit before working with the second connection.
The module gains a REGRESS_OPTS to be able to look at the regress
library's dlpath.

This issue could be reproduced with a hardcoded sleep() in the shmem
exit callback, and the CI has been able to trigger it sporadically.

Oversight in f587338dec87.

Reported-by: Bharath Rupireddy
Reviewed-by: Andrey Borodin
Discussion: https://postgr.es/m/ZhOd3NXAutteokGL@paquier.xyz
src/test/modules/injection_points/Makefile
src/test/modules/injection_points/expected/injection_points.out
src/test/modules/injection_points/meson.build
src/test/modules/injection_points/sql/injection_points.sql