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 1lIKJu-0008SF-2G for pgsql-general@arkaria.postgresql.org; Fri, 05 Mar 2021 23:57:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lIKJq-0002qj-EM for pgsql-general@arkaria.postgresql.org; Fri, 05 Mar 2021 23:57:18 +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 1lIKJq-0002qc-70 for pgsql-general@lists.postgresql.org; Fri, 05 Mar 2021 23:57:18 +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 1lIKJk-0003RF-8Y for pgsql-general@postgresql.org; Fri, 05 Mar 2021 23:57:16 +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 125Nv8FH1520806; Fri, 5 Mar 2021 18:57:09 -0500 From: Tom Lane To: Jerry Sievers cc: Jeremy Finzel , Postgres General Subject: Re: Unkillable processes creating millions of tiny temp files In-reply-to: <875z25jhc6.fsf@jsievers.enova.com> References: <1517658.1614983320@sss.pgh.pa.us> <875z25jhc6.fsf@jsievers.enova.com> Comments: In-reply-to Jerry Sievers message dated "Fri, 05 Mar 2021 17:44:57 -0600" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1520804.1614988628.1@sss.pgh.pa.us> Date: Fri, 05 Mar 2021 18:57:08 -0500 Message-ID: <1520805.1614988628@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Jerry Sievers writes: > Tom Lane writes: >> The "unkillable" aspect is odd, but I wonder if that's just a red >> herring. A query that's generated lots of temp files will try to >> clean them up at termination, so maybe the backend is just sitting >> there removing temp files before it'll give control back. > I believe this is confirmed. I see that the backend after being > sig-term'd are now cycling through unlinks as seen by strace -p $pid. > None too quickly I might add and as mentioned earlier, the number of > these files is in the millions so it's hard to predict when cleanup will > finish. Hm. I don't recall exactly what sort of data structure we use to track open temp files, but it's certainly plausible that it's not too efficient with millions of temp files :-( > As we did one night prior, a hard shutdown got the rogue jobs closed a > lot more quickly and we noticed that on the recovery restart, Pg took > about 15 minutes to clear >23M files from the temp area. I assume we'd > experience the same again if we need to do it. Not sure how fast that is either. If you need to do it again, you could try manually rm'ing everything under the pgsql_tmp directory before letting the postmaster start. regards, tom lane