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 1mH9Yz-0001M3-Mc for pgsql-committers@arkaria.postgresql.org; Fri, 20 Aug 2021 18:48:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mH9Yy-0005Wz-8B for pgsql-committers@arkaria.postgresql.org; Fri, 20 Aug 2021 18:48:20 +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 1mH9Yy-0005Wr-2N for pgsql-committers@lists.postgresql.org; Fri, 20 Aug 2021 18:48:20 +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 1mH9Yv-0000AS-UM for pgsql-committers@lists.postgresql.org; Fri, 20 Aug 2021 18:48:19 +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 17KIlwkQ1957504; Fri, 20 Aug 2021 14:47:58 -0400 From: Tom Lane To: Daniel Gustafsson cc: Fabien COELHO , Peter Eisentraut , pgsql-committers@lists.postgresql.org Subject: Re: pgsql: psql: Add test for query canceling In-reply-to: <5F16EBAA-30D3-4C0D-840C-C2FF2739E370@yesql.se> References: <5F16EBAA-30D3-4C0D-840C-C2FF2739E370@yesql.se> Comments: In-reply-to Daniel Gustafsson message dated "Fri, 20 Aug 2021 20:27:32 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <1957502.1629485278.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 20 Aug 2021 14:47:58 -0400 Message-ID: <1957503.1629485278@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Daniel Gustafsson writes: > If we want the test to run but not fail the entire test suite if it fail= s then > it should use a TODO block instead, but that=E2=80=99s intended for test= s known to fail > and this doesn=E2=80=99t seem to fall in that category. That seems pretty useless. If we did break things in this area, such a test would not help us notice. The problem with the test seems blindingly obvious from here: it is assuming first that psql will start fast enough to print its PID within one second, and next that we'll be able to issue the cancel (and have the backend react) in less than 2 seconds more. This seems about guaranteed to fail on cache-clobber animals, for example, but animals that are merely slow or overloaded would have issues too. I think you should drop the overly-cute bit with a SIGALRM handler, and instead have a loop-with-delay around an attempt to read the psql.pid file, after launching the psql run without an immediate wait for termination. That gets rid of the first problem (though you still want the loop to timeout eventually, it could wait up to say 180 seconds, as we do elsewhere). Then the second problem is easy to solve by making the pg_sleep delay twice as much. regards, tom lane