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 1mHBx0-0005ev-NZ for pgsql-committers@arkaria.postgresql.org; Fri, 20 Aug 2021 21:21:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mHBwy-0001gX-Gq for pgsql-committers@arkaria.postgresql.org; Fri, 20 Aug 2021 21:21:16 +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 1mHBwy-0001gP-Ai for pgsql-committers@lists.postgresql.org; Fri, 20 Aug 2021 21:21:16 +0000 Received: from smtp.outgoing.loopia.se ([93.188.3.37]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mHBwt-0002Cu-LA for pgsql-committers@lists.postgresql.org; Fri, 20 Aug 2021 21:21:15 +0000 Received: from s807.loopia.se (localhost [127.0.0.1]) by s807.loopia.se (Postfix) with ESMTP id 8EC2424647F5 for ; Fri, 20 Aug 2021 23:21:10 +0200 (CEST) Received: from s499.loopia.se (unknown [172.22.191.6]) by s807.loopia.se (Postfix) with ESMTP id 7F2BC2E28E1B; Fri, 20 Aug 2021 23:21:10 +0200 (CEST) Received: from s898.loopia.se (unknown [172.22.191.5]) by s499.loopia.se (Postfix) with ESMTP id 749561CE6294; Fri, 20 Aug 2021 23:21:10 +0200 (CEST) X-Virus-Scanned: amavisd-new at amavis.loopia.se X-Spam-Flag: NO X-Spam-Score: -1 X-Spam-Level: X-Spam-Status: No, score=-1 tagged_above=-999 required=6.2 tests=[ALL_TRUSTED=-1] autolearn=disabled Received: from s499.loopia.se ([172.22.191.6]) by s898.loopia.se (s898.loopia.se [172.22.190.17]) (amavisd-new, port 10024) with LMTP id puO9t4U81pkU; Fri, 20 Aug 2021 23:21:10 +0200 (CEST) X-Loopia-Auth: user X-Loopia-User: daniel@yesql.se X-Loopia-Originating-IP: 89.255.232.193 Received: from [192.168.72.144] (customer-89-255-232-193.stosn.net [89.255.232.193]) (Authenticated sender: daniel@yesql.se) by s499.loopia.se (Postfix) with ESMTPSA id 041991CE630C; Fri, 20 Aug 2021 23:21:10 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Subject: Re: pgsql: psql: Add test for query canceling From: Daniel Gustafsson In-Reply-To: <1957503.1629485278@sss.pgh.pa.us> Date: Fri, 20 Aug 2021 23:21:09 +0200 Cc: Fabien COELHO , Peter Eisentraut , pgsql-committers@lists.postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <5F16EBAA-30D3-4C0D-840C-C2FF2739E370@yesql.se> <1957503.1629485278@sss.pgh.pa.us> To: Tom Lane X-Mailer: Apple Mail (2.3608.120.23.2.7) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 20 Aug 2021, at 20:47, Tom Lane wrote: >=20 > Daniel Gustafsson writes: >> If we want the test to run but not fail the entire test suite if it = fails then >> it should use a TODO block instead, but that=E2=80=99s intended for = tests known to fail >> and this doesn=E2=80=99t seem to fall in that category. >=20 > That seems pretty useless. If we did break things in this area, > such a test would not help us notice. For sure. I wasn=E2=80=99t advocating it, merely indicating that the = SKIP block isn=E2=80=99t working the way attributed to upthread. > 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. >=20 > 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. This could perhaps be done with a PostgresNode::interactive_psql = session? I used that in a similar, but far from the same, test setup in the online checksums patchset. -- Daniel Gustafsson https://vmware.com/