Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ofaew-0006GT-B6 for pgsql-hackers@arkaria.postgresql.org; Tue, 04 Oct 2022 05:40:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ofaeu-0000bC-TE for pgsql-hackers@arkaria.postgresql.org; Tue, 04 Oct 2022 05:40:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ofaeu-0000aA-Jp for pgsql-hackers@lists.postgresql.org; Tue, 04 Oct 2022 05:40:00 +0000 Received: from relay5-d.mail.gandi.net ([2001:4b98:dc4:8::225]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ofaes-0002cs-1e for pgsql-hackers@postgresql.org; Tue, 04 Oct 2022 05:40:00 +0000 Received: (Authenticated sender: adsend@dunslane.net) by mail.gandi.net (Postfix) with ESMTPSA id 05F1A1C000A; Tue, 4 Oct 2022 05:39:53 +0000 (UTC) Message-ID: <7579f627-aad4-7a04-1a98-033cc6b3cca5@dunslane.net> Date: Tue, 4 Oct 2022 01:39:51 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: ssl tests aren't concurrency safe due to get_free_port() Content-Language: en-US To: Andres Freund , pgsql-hackers@postgresql.org, Tom Lane References: <20221002164931.d57hlutrcz4d2zi7@awork3.anarazel.de> From: Andrew Dunstan In-Reply-To: <20221002164931.d57hlutrcz4d2zi7@awork3.anarazel.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2022-10-02 Su 12:49, Andres Freund wrote: > > 2) Use a lockfile containing a pid to protect the choice of a port within a > build directory. Before accepting a port get_free_port() would check if the > a lockfile exists for the port and if so, if the test using it is still > alive. That will protect against racyness between multiple tests inside a > build directory, but won't protect against races between multiple builds > running concurrently on a machine (e.g. on a buildfarm host) > > I think this is the right solution. To deal with the last issue, the lockdir should be overrideable, like this:   my $port_lockdir = $ENV{PG_PORT_LOCKDIR} || $build_dir; Buildfarm animals could set this, probably to the global lockdir (see run_branches.pl). Prior to that, buildfarm owners could do that manually. There are numerous examples of lockfile code in the buildfarm sources. I'll try to hack something up. cheers andrew -- Andrew Dunstan EDB: https://www.enterprisedb.com