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 1okRar-0001R9-Mx for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Oct 2022 14:59:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1okRaq-0006xQ-7Z for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Oct 2022 14:59:52 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1okRap-0006vN-UQ for pgsql-hackers@lists.postgresql.org; Mon, 17 Oct 2022 14:59:51 +0000 Received: from relay11.mail.gandi.net ([217.70.178.231]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1okRaj-00016n-N9 for pgsql-hackers@postgresql.org; Mon, 17 Oct 2022 14:59:48 +0000 Received: (Authenticated sender: adsend@dunslane.net) by mail.gandi.net (Postfix) with ESMTPSA id 11C03100014; Mon, 17 Oct 2022 14:59:34 +0000 (UTC) Message-ID: <52266bf8-bf38-fdfa-9a77-1568f82b63b3@dunslane.net> Date: Mon, 17 Oct 2022 10:59:32 -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 From: Andrew Dunstan To: Andres Freund , pgsql-hackers@postgresql.org, Tom Lane References: <20221002164931.d57hlutrcz4d2zi7@awork3.anarazel.de> <7579f627-aad4-7a04-1a98-033cc6b3cca5@dunslane.net> In-Reply-To: <7579f627-aad4-7a04-1a98-033cc6b3cca5@dunslane.net> 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-04 Tu 01:39, Andrew Dunstan wrote: > 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. > > The problem here is that Cluster.pm doesn't have any idea where the build directory is, or even if there is one present at all. meson does appear to let us know that, however, with MESON_BUILD_ROOT, so probably the best thing would be to use PG_PORT_LOCKDIR if it's set, otherwise MESON_BUILD_ROOT if it's set, otherwise the tmp_check directory. If we want to backport to the make system we could export top_builddir somewhere. cheers andrew -- Andrew Dunstan EDB: https://www.enterprisedb.com