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 1lMzc4-00033a-MO for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Mar 2021 20:51:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lMzc3-0002mN-K2 for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Mar 2021 20:51:23 +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 1lMzc3-0002ju-9s for pgsql-hackers@lists.postgresql.org; Thu, 18 Mar 2021 20:51:23 +0000 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lMzbw-0002qU-9R for pgsql-hackers@lists.postgresql.org; Thu, 18 Mar 2021 20:51:22 +0000 Received: by mail-ej1-x62b.google.com with SMTP id w3so6101003ejc.4 for ; Thu, 18 Mar 2021 13:51:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Y3X4yCe4/WyNOdcw334qKES+mxIl4AoNlqDSWdkr+As=; b=PI/Lk9iAuyUGYftkT6WJ/UZgbLhLvxzKiz6MfJRQyJ4XOViz0E8b9jOYEaDf/p6pUD nyKM59XYfpuZa1EhFYmr3wZTLOC7VnflTFUV8KUuJOLLhzjSLev1mkZqcpmjyp33U+bf B+s5XijfZsVjdo9DH2LtjY0JHxpbz2Y81oK1VJe3G9PctSJu/ILQ++XUcPcHe6vDMUyV hNLY6TdlvAOuMgj1pBDF0yV4pKF7CADscQCahW5TDAAOO/OF7NEkuGHpHT4leOsQmhT9 PJoK5A5FLZ5+n1xjJybSLvRCWoCzFXWOPOuy8wbJ6+hsLSDJwWYOJowzNyOoPFuL1Wzn SvFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Y3X4yCe4/WyNOdcw334qKES+mxIl4AoNlqDSWdkr+As=; b=W39rjn4RUYIhwdbzIF/IQQRUFw6PkBPXdScY5AfeHb7YJEgyQZZujpfsarAp6++/Ru sK7HYF+pbnd4WdJ2/Cr5qbtflqcOKyI9JUJ85si7uih4gvWpTHTbqEJzfB6YhHN6vSp/ VCINIx6WwStQzZnHBel7PWQzPU778MaCbW0eOFfETlmNFFK47kWAvlN3U7Wij8xxRii+ Yan8ahrkc3A/kR7K+Ys3DQ2K+4gaBMAKxih+9xeOzXgZ+N996QCl1g9ZbW0S8kT8eOS6 AboPCIe//7JwQxRqwBweCvxe8XI9v3+J8pTDVYUq+WQzQDi09tZEt9h1dr4za/SLY89w nXEA== X-Gm-Message-State: AOAM533D5VRP7FZLmq/xcs8t6JP8PsrBiga/+mA/LyR8h+VdEs2FPHt7 c9kx3ih5aJTnf5L6XNNGAvfQv7qDoLCX2b8NKectdQCBm9RbLtCBEyuJH/OAHRostJy/gwxF4RO JY3Fbqz9eFpbDqrfbITBF03rli6DxdJbqX6HdoxegT9Gnv9fQs3svO2FB8LREYeTdSCFNfsSv+G 1NWTyxB22jIJ5ABS67aka2GAzcKWLmCqHabjAMPna0Ir785oBhyKTH X-Google-Smtp-Source: ABdhPJw/G9uumXUA6NLCS21aVxll1cd/2grDwl7J0YooUL7M9Wwhw3kcw4Rpb3wa/zLe5mitJg+QNg== X-Received: by 2002:a17:906:6044:: with SMTP id p4mr532667ejj.82.1616100674683; Thu, 18 Mar 2021 13:51:14 -0700 (PDT) Received: from [10.137.0.20] (ip-86-49-253-127.net.upcbroadband.cz. [86.49.253.127]) by smtp.gmail.com with ESMTPSA id z17sm2537211eju.27.2021.03.18.13.51.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 18 Mar 2021 13:51:13 -0700 (PDT) Subject: Re: cleanup temporary files after crash To: Euler Taveira , Thomas Munro , Michael Paquier Cc: Euler Taveira , Anastasia Lubennikova , Tomas Vondra , PostgreSQL Hackers , Tom Lane References: <20201028184252.5vpoe65kcfebbmmf@development> <20201101012555.GC3000@paquier.xyz> <1982ee3c-54c3-280a-806a-fd28ad8f19e6@postgrespro.ru> <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> From: Tomas Vondra Message-ID: <1ec33f3d-ea4c-28c8-502c-3eb0a008a6ac@enterprisedb.com> Date: Thu, 18 Mar 2021 21:51:11 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <54663718-1d87-46f2-a27b-e7edacbfae0d@www.fastmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 3/18/21 9:06 PM, Euler Taveira wrote: > On Thu, Mar 18, 2021, at 4:20 PM, Tomas Vondra wrote: >> I think a better way to test this would be to use a tuple lock: > I predicated such issues with this test. Your suggestion works for me. Maybe > you should use less rows in the session 2 query. > >> setup: >> >>   create table t (a int unique); >> >> session 1: >> >>   begin; >>   insert into t values (1); >>   ... keep open ... >> >> session 2: >> >>    begin; >>    set work_mem = '64kB'; >>    insert into t select i from generate_series(1,10000) s(i); >>    ... should block ... >> >> Then, once the second session gets waiting on the tuple, kill the >> backend. We might as well test that there actually is a temp file first, >> and then test that it disappeared. > Your suggestion works for me. Maybe you could use less rows in the session 2 > query. I experimented with 1k rows and it generates a temporary file. > OK. Can you prepare a patch with the proposed test approach? FWIW I can reproduce this on a 32-bit ARM system (rpi4), where 500 rows simply does not use a temp file, and with 1000 rows it works fine. On the x86_64 the temp file is created even with 500 rows. So there clearly is some platform dependency, not sure if it's due to 32/64 bits, alignment or something else. In any case, the 500 rows seems to be just on the threshold. We need to do both - stop using the timing and increase the number of rows, to consistently get temp files. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company