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 1lN5k7-0008Jx-EO for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Mar 2021 03:24:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lN5k5-00073E-6Y for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Mar 2021 03:24:05 +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 1lN5k4-000736-W4 for pgsql-hackers@lists.postgresql.org; Fri, 19 Mar 2021 03:24:04 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lN5k2-0007gb-E7 for pgsql-hackers@lists.postgresql.org; Fri, 19 Mar 2021 03:24:04 +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 12J3Nsm24030090; Thu, 18 Mar 2021 23:23:54 -0400 From: Tom Lane To: Tomas Vondra cc: Euler Taveira , Thomas Munro , Michael Paquier , Euler Taveira , Anastasia Lubennikova , Tomas Vondra , PostgreSQL Hackers Subject: Re: cleanup temporary files after crash In-reply-to: <19bc3276-6280-43bd-d868-ab3cb146266a@enterprisedb.com> References: <363cb85c-3a03-9a49-b830-8b645c1241d9@enterprisedb.com> <4245d284-97b2-4056-96c2-455792d9b564@www.fastmail.com> <8740f056-a7c0-ff12-0a50-de5324a928ee@enterprisedb.com> <822e3a60-56a1-219d-c473-365751c3e108@enterprisedb.com> <54663718-1d87-46f2-a27b-e7edacbfae0d@www.fastmail.com> <1ec33f3d-ea4c-28c8-502c-3eb0a008a6ac@enterprisedb.com> <34226249-c5ba-4780-a1bb-f3433d19716e@www.fastmail.com> <05d307fc-8391-4091-b279-1b3214658f10@www.fastmail.com> <049a2752-fc99-194d-31b2-b15ffa914cd4@enterprisedb.com> <482a6498-7713-e937-c554-7d235c415fba@enterprisedb.com> <112f0847-a71! a-eec2-e561-2d39dc26127a@enterprisedb.com> <4028905.1616122655@sss.pgh.pa.us> <19bc3276-6280-43bd-d868-ab3cb146266a@enter! prisedb.com> Comments: In-reply-to Tomas Vondra message dated "Fri, 19 Mar 2021 04:07:05 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4030088.1616124234.1@sss.pgh.pa.us> Date: Thu, 18 Mar 2021 23:23:54 -0400 Message-ID: <4030089.1616124234@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk [ reads code... ] ... no, I think the problem is the test is still full of race conditions. In the first place, waiting till you see the output of a SELECT that's before the useful query is not enough to guarantee that the useful query is done, or even started. That's broken on both sessions. In the second place, even if the second INSERT has started, you don't know that it's reached the point of blocking on the tuple conflict yet. Which in turn means that it might not've filled its tuplestore yet. In short, this script is designed to ensure that the test query can't finish too soon, but that proves nothing about whether the test query has even started. And since you also haven't really guaranteed that the intended-to-be-blocking query is done, I don't think that the first condition really holds either. regards, tom lane