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 1mIZm0-0003O7-Fv for pgsql-committers@arkaria.postgresql.org; Tue, 24 Aug 2021 16:59:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mIZly-0001cA-KB for pgsql-committers@arkaria.postgresql.org; Tue, 24 Aug 2021 16:59:38 +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 1mIZly-0001c0-66 for pgsql-committers@lists.postgresql.org; Tue, 24 Aug 2021 16:59:38 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mIZlr-0001tg-H6 for pgsql-committers@lists.postgresql.org; Tue, 24 Aug 2021 16:59:36 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 17OGxAWK350198; Tue, 24 Aug 2021 12:59:10 -0400 From: Tom Lane To: Peter Eisentraut cc: Daniel Gustafsson , Fabien COELHO , pgsql-committers@lists.postgresql.org Subject: Re: pgsql: psql: Add test for query canceling In-reply-to: <9f46b102-da4d-8312-54f0-1f3bc10b453c@enterprisedb.com> References: <5F16EBAA-30D3-4C0D-840C-C2FF2739E370@yesql.se> <1957503.1629485278@sss.pgh.pa.us> <9f46b102-da4d-8312-54f0-1f3bc10b453c@enterprisedb.com> Comments: In-reply-to Peter Eisentraut message dated "Tue, 24 Aug 2021 18:43:38 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <350195.1629824350.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 24 Aug 2021 12:59:10 -0400 Message-ID: <350197.1629824350@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Peter Eisentraut writes: > Here is a proposal. It waits separately for the pid file to appear and = > also checks for the sleep query to be registered by the backend, so it = > doesn't have any more dependencies on things happening "fast enough". = > And it's also faster in the normal case now. Thoughts? That looks pretty solid to me, and I can confirm that it passes on wrasse's host. The only nit I can find to pick is that this: + usleep(10_000) until -s "$tempdir/psql.pid" or ($count++ > 180 * 100 and= die 'pid file did not appear'); basically assumes that psql.pid will be written atomically. It'd be marginally safer to wait till psql.pid can be seen to contain a newline. I don't think that would be too hard to do, if you put the slurp_file call inside the wait loop and inspect its result. regards, tom lane