Fix crash-restart race in 041_checkpoint_at_promote.pl The buildfarm member bushmaster reported failures in the final test query in 041_checkpoint_at_promote.pl with "the database system is in recovery mode".
After killing a backend to trigger crash recovery, the test should wait for the postmaster to terminate the remaining server processes and restart the server, then wait for recovery to finish and connections to be accepted before running the final query. Previously, the test assumed that the killed backend's connection closing meant the postmaster had noticed the crash and begun restarting. However, the connection can close before the postmaster notices the crash. The subsequent connection check can then succeed before recovery starts, causing the test to mistake this for recovery having completed. The final query could then run during recovery and fail. Fix this by waiting for the postmaster to log that all server processes have terminated and it is reinitializing before checking that connections are accepted again. This ensures that the postmaster has noticed the crash and begun restarting before the test waits for recovery to finish. Backpatch to v17, where this test was introduced. Reported-by: Alexander Lakhin <[email protected]> Author: Fujii Masao <[email protected]> Reviewed-by: Ayush Tiwari <[email protected]> Discussion: https://postgr.es/m/[email protected] Backpatch-through: 17 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/6621f2b062e20d8d2ea2cc225b2509ec9fca45a8 Modified Files -------------- src/test/recovery/t/041_checkpoint_at_promote.pl | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
