pgsql: Prevent port collisions between concurrent TAP tests

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Prevent port collisions between concurrent TAP tests
Date: 2022-11-22 15:56:43
Message-ID: E1oxVda-000NI3-MB@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Prevent port collisions between concurrent TAP tests

Currently there is a race condition where if concurrent TAP tests both
test that they can open a port they will assume that it is free and use
it, causing one of them to fail. To prevent this we record a reservation
using an exclusive lock, and any TAP test that discovers a reservation
checks to see if the reserving process is still alive, and looks for
another free port if it is.

Ports are reserved in a directory set by the environment setting
PG_TEST_PORT_DIR, or if that doesn't exist a subdirectory of the top
build directory as set by Makefile.global, or its own
tmp_check directory.

The prove_check recipe in Makefile.global.in is extended to export
top_builddir to the TAP tests. This was already exported by the
prove_installcheck recipes.

Per complaint from Andres Freund

Backpatched from 9b4eafcaf4 to all live branches

Discussion: https://postgr.es/m/20221002164931.d57hlutrcz4d2zi7@awork3.anarazel.de

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/870d6218e6d73dca8ec37b4d7f5076b74eeaeffe

Modified Files
--------------
src/Makefile.global.in | 1 +
src/test/perl/PostgresNode.pm | 64 +++++++++++++++++++++++++++++++++++++++----
2 files changed, 60 insertions(+), 5 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2022-11-22 19:41:15 pgsql: YA attempt at taming worst-case behavior of get_actual_variable_
Previous Message Alvaro Herrera 2022-11-22 10:28:30 pgsql: Remove useless MERGE test