pgsql: tests: Fix race condition in postmaster/002_connection_limits

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: tests: Fix race condition in postmaster/002_connection_limits
Date: 2025-03-07 18:22:56
Message-ID: E1tqcLY-001Iqv-1t@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

tests: Fix race condition in postmaster/002_connection_limits

The test occasionally failed due to unexpected connection limit errors being
encountered after having waited for FATAL errors on another connection. These
spurious failures were caused by the the backend reporting FATAL errors to the
client before detaching from the PGPROC entry. Adding a sleep(1) before
proc_exit() makes it easy to reproduce that problem.

To fix the issue, add a helper function that waits for postmaster to notice
the process having exited. For now this is implemented by waiting for the
DEBUG2 message that postmaster logs in that case. That's not the prettiest
fix, but simple. If we notice this problem elsewhere, it might be worthwhile
to make this more general, e.g. by adding an injection point.

Reported-by: Tomas Vondra <tomas(at)vondra(dot)me>
Diagnosed-by: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Reviewed-by: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Tested-by: Tomas Vondra <tomas(at)vondra(dot)me>
Discussion: https://postgr.es/m/ggflhkciwdyotpoie323chu2c2idpjk5qimrn462encwx2io7s@thmcxl7i6dpw

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/71d1ed6fe129935ce2764c5d34924512ed046f69

Modified Files
--------------
src/test/postmaster/t/002_connection_limits.pl | 35 +++++++++++++++++++++++---
1 file changed, 32 insertions(+), 3 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2025-03-07 18:24:29 pgsql: Include column name in build_attrmap_by_position's error reports
Previous Message Álvaro Herrera 2025-03-07 18:20:34 Re: pgsql: reindexdb: Add the index-level REINDEX with multiple jobs