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 1lNFxe-00074f-DB for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Mar 2021 14:18:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lNFxd-0000jk-3O for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Mar 2021 14:18:45 +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 1lNFxc-0000jd-9M for pgsql-hackers@lists.postgresql.org; Fri, 19 Mar 2021 14:18:44 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lNFxY-00053l-Oj for pgsql-hackers@lists.postgresql.org; Fri, 19 Mar 2021 14:18:43 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 836565C0195; Fri, 19 Mar 2021 10:18:37 -0400 (EDT) Received: from imap21 ([10.202.2.71]) by compute2.internal (MEProxy); Fri, 19 Mar 2021 10:18:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eulerto.com; h= mime-version:message-id:in-reply-to:references:date:from:to:cc :subject:content-type; s=fm1; bh=vb7xHXmHz2K6mgy75e4peAWGwvfQ274 SkKTJf+DdVTw=; b=1uov0NgejYJzOMi/o2SjUP8YLvfnkvF6FB7QnGTQXx3T1Qj 4yzM2WNJ4skGDYu/iOit+BTF7rZAqoL5uognHu9PSEMP/3TKSJYiW80hSgRcI5lv x+mpjxS4zezfqZIy6TMQlDz6+wusb1CR/KFdXIc7nvL70LDCX3gIuiD9sH3ZNCJ0 o+tPlyVrYAMIBcZuz8vNPykXISpO1BZ835eGFdW5Spgbc5Kr9TQjqSolQZkC3+Ps FrrRibfOeQyqhLmXaaiF2Mq2Hj/gc4rRgJqVZD0ieVsQgwA1cpRpysRh/QBRdMQL g1bCg9FGPkPk3UUK6fxpesXcjQSd6KobJN7IwLQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=vb7xHX mHz2K6mgy75e4peAWGwvfQ274SkKTJf+DdVTw=; b=WKcQtBuqIzRnZnYBFjLjZC SgFyWmN9q8qdGQPETRsbI5SU320yuH0Hc3mou8a7nICZhmABn3s6JV4JnTh7pvRg m+kbsl6tSToLf66mXqdu+6XjDj60Tmd5W6b8yG02PvEycbHkKy1LAnJhbksE+1k5 gc/J5s3Z+f6iOuRpuBhgEzYHhmccYJhCHUJ3EuWFeVLFSxBOGHZ6i8OYRe3llfdl LqEkfR2h3YH2rim5bonwKUtCWwc4OuqvqIgPRanuDydRp1D6BY7+K7U1VeqrnMFH Oq8A/gHyHN2L7n9orRezvX18229igvw4ZdlnmkTZbpcThxU8Xkn/81x6nkSIgHjw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudefkedgieegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesmhdtreerreertdenucfhrhhomhepfdfguhhl vghrucfvrghvvghirhgrfdcuoegvuhhlvghrsegvuhhlvghrthhordgtohhmqeenucggtf frrghtthgvrhhnpefhvdelgfekvdetjeejtefhudejfeeileetjeeufeetffegjedtvdeu kedtgeffgeenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepvghulhgvrhesvghu lhgvrhhtohdrtghomh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id C3F6251C005F; Fri, 19 Mar 2021 10:18:35 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-206-g078a48fda5-fm-20210226.001-g078a48fd Mime-Version: 1.0 Message-Id: <6eff9861-b059-4eaa-ae70-e5ff877b6448@www.fastmail.com> In-Reply-To: <4030089.1616124234@sss.pgh.pa.us> 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> <4030089.1616124234@sss.pgh.pa.us> Date: Fri, 19 Mar 2021 11:17:50 -0300 From: "Euler Taveira" To: "Tom Lane" , "Tomas Vondra" Cc: "Thomas Munro" , "Michael Paquier" , "Euler Taveira" , "Anastasia Lubennikova" , "Tomas Vondra" , "PostgreSQL Hackers" Subject: Re: cleanup temporary files after crash Content-Type: multipart/mixed; boundary=1f63f807d8fb4451a6b264ad8d9543c1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --1f63f807d8fb4451a6b264ad8d9543c1 Content-Type: multipart/alternative; boundary=3397fecc8cb94beeb2bbd807fcfe1e41 --3397fecc8cb94beeb2bbd807fcfe1e41 Content-Type: text/plain On Fri, Mar 19, 2021, at 12:23 AM, Tom Lane wrote: > [ 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. That's an ugly and fragile mechanism to workaround the fact that pump_until reacts after you have the query return. > 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. In order to avoid the race condition between filling the tuplestore and killing the backend, we could use a pool_query_until() before SIGKILL to wait the temporary file being created. Do you think this modification will make this test more stable? -- Euler Taveira EDB https://www.enterprisedb.com/ --3397fecc8cb94beeb2bbd807fcfe1e41 Content-Type: text/html Content-Transfer-Encoding: quoted-printable
On Fri, Ma= r 19, 2021, at 12:23 AM, Tom Lane wrote:
[ 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 starte= d.  That's broken on both sessions.
That= 's an ugly and fragile mechanism to workaround the fact that pump_until<= br>
reacts after you have the query return.

=
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 tuplesto= re yet.

In short, this script is designed t= o ensure that the test query can't
finish too soon, but th= at proves nothing about whether the test query
has even st= arted.  And since you also haven't really guaranteed that the
intended-to-be-blocking query is done, I don't think that the f= irst
condition really holds either.
=
In order to avoid the race condition between filling the tuplestore= and killing
the backend, we could use a pool_query_until(= ) before SIGKILL to wait the
temporary file being created.= Do you think this modification will make this
test more s= table?


<= div class=3D"signature">--
Euler Tavei= ra
=

--3397fecc8cb94beeb2bbd807fcfe1e41-- --1f63f807d8fb4451a6b264ad8d9543c1 Content-Disposition: attachment;filename="v3-fix-crash-temp-files.patch" Content-Type: text/x-patch; name="v3-fix-crash-temp-files.patch" Content-Transfer-Encoding: BASE64 ZGlmZiAtLWdpdCBhL3NyYy90ZXN0L3JlY292ZXJ5L3QvMDIyX2NyYXNoX3RlbXBfZmlsZXMu cGwgYi9zcmMvdGVzdC9yZWNvdmVyeS90LzAyMl9jcmFzaF90ZW1wX2ZpbGVzLnBsCmluZGV4 IDgwNDQ4NDliNzMuLjQxYTkxZWJkMDYgMTAwNjQ0Ci0tLSBhL3NyYy90ZXN0L3JlY292ZXJ5 L3QvMDIyX2NyYXNoX3RlbXBfZmlsZXMucGwKKysrIGIvc3JjL3Rlc3QvcmVjb3ZlcnkvdC8w MjJfY3Jhc2hfdGVtcF9maWxlcy5wbApAQCAtMTAwLDYgKzEwMCwxMSBAQCBvayhwdW1wX3Vu dGlsKCRraWxsbWUsIFwka2lsbG1lX3N0ZG91dCwgcXIvaW4tcHJvZ3Jlc3MtYmVmb3JlLXNp Z2tpbGwvbSksCiAka2lsbG1lX3N0ZG91dCA9ICcnOwogJGtpbGxtZV9zdGRlcnIgPSAnJzsK IAorIyBXYWl0IHRpbGwgYSB0ZW1wb3JhcnkgZmlsZSBpcyBjcmVhdGVkCiskbm9kZS0+cG9s bF9xdWVyeV91bnRpbCgKKwkncG9zdGdyZXMnLAorCSdTRUxFQ1QgQ09VTlQoMSkgRlJPTSBw Z19sc19kaXIoJCRiYXNlL3Bnc3FsX3RtcCQkKScsICcxJyk7CisKICMgS2lsbCB3aXRoIFNJ R0tJTEwKIG15ICRyZXQgPSBUZXN0TGliOjpzeXN0ZW1fbG9nKCdwZ19jdGwnLCAna2lsbCcs ICdLSUxMJywgJHBpZCk7CiBpcygkcmV0LCAwLCAna2lsbGVkIHByb2Nlc3Mgd2l0aCBLSUxM Jyk7CkBAIC0xNjgsNiArMTczLDExIEBAIG9rKHB1bXBfdW50aWwoJGtpbGxtZSwgXCRraWxs bWVfc3Rkb3V0LCBxci9pbi1wcm9ncmVzcy1iZWZvcmUtc2lna2lsbC9tKSwKICRraWxsbWVf c3Rkb3V0ID0gJyc7CiAka2lsbG1lX3N0ZGVyciA9ICcnOwogCisjIFdhaXQgdGlsbCBhIHRl bXBvcmFyeSBmaWxlIGlzIGNyZWF0ZWQKKyRub2RlLT5wb2xsX3F1ZXJ5X3VudGlsKAorCSdw b3N0Z3JlcycsCisJJ1NFTEVDVCBDT1VOVCgxKSBGUk9NIHBnX2xzX2RpcigkJGJhc2UvcGdz cWxfdG1wJCQpJywgJzEnKTsKKwogIyBLaWxsIHdpdGggU0lHS0lMTAogJHJldCA9IFRlc3RM aWI6OnN5c3RlbV9sb2coJ3BnX2N0bCcsICdraWxsJywgJ0tJTEwnLCAkcGlkKTsKIGlzKCRy ZXQsIDAsICdraWxsZWQgcHJvY2VzcyB3aXRoIEtJTEwnKTsK --1f63f807d8fb4451a6b264ad8d9543c1--