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 1lIK8H-0008BN-4x for pgsql-general@arkaria.postgresql.org; Fri, 05 Mar 2021 23:45:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lIK8E-0007y0-Nn for pgsql-general@arkaria.postgresql.org; Fri, 05 Mar 2021 23:45: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 1lIK8E-0007xr-4C for pgsql-general@lists.postgresql.org; Fri, 05 Mar 2021 23:45:18 +0000 Received: from resqmta-po-06v.sys.comcast.net ([2001:558:fe16:19:96:114:154:165]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lIK87-0003Gl-Ao for pgsql-general@postgresql.org; Fri, 05 Mar 2021 23:45:16 +0000 Received: from resomta-po-08v.sys.comcast.net ([96.114.154.232]) by resqmta-po-06v.sys.comcast.net with ESMTP id IGtflhhWHskgGIK85l8ef0; Fri, 05 Mar 2021 23:45:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=20190202a; t=1614987909; bh=iI9L00kTxMo9f9Gn59LmTAvjNeMESuU48owd2oWIH6o=; h=Received:Received:Received:From:To:Subject:Date:Message-ID: MIME-Version:Content-Type; b=Jruco3J2Zl95WitK//UIavMukvIYYXnGCijf4No16M69yperVe9EIcpeAvZYNaso6 JKNnc0KUAXqIbvstYNve58ndaGrpd2EoQ/XBl+SJB8/4Bpku2NSFMs/wvrJlFhZtTf 0esXlpwX4mvO5nJyuzN9Nl4f2ZEwTEZSZ/I7iup9PWEjv4+rPb8lFMbmcNRbudu46F qSiAvtC+3ahXtVBYeE9kYQzEpqWpd755xJxIYSw7bx2qrYFuwEbXI27mEgqfgb0aVT M8pRXGzFG4sSpoJXeAjqdpbUE9VdEauPGvivx5MzHtG6BRcoIzFeoRMCFmRhFYp+Jt mquf4WoNRZaKg== Received: from jsievers.comcast.net ([12.187.116.132]) by resomta-po-08v.sys.comcast.net with ESMTPA id IK7tluCACm83yIK7uluWZx; Fri, 05 Mar 2021 23:45:07 +0000 X-Xfinity-VAAS: gggruggvucftvghtrhhoucdtuddrgeduledruddtjedgudefucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuvehomhgtrghsthdqtfgvshhipdfqfgfvpdfpqffurfetoffkrfenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufhfffgjkfgfgggtsehttdertddtredtnecuhfhrohhmpeflvghrrhihucfuihgvvhgvrhhsuceoghhsihgvvhgvrhhsudelsegtohhmtggrshhtrdhnvghtqeenucggtffrrghtthgvrhhnpeeijeeuteeifeeutddttdeiieevueegieetuefhueeihfeulefgieevudetffdvleenucfkphepuddvrddukeejrdduudeirddufedvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehhvghlohepjhhsihgvvhgvrhhsrdgtohhmtggrshhtrdhnvghtpdhinhgvthepuddvrddukeejrdduudeirddufedvpdhmrghilhhfrhhomhepghhsihgvvhgvrhhsudelsegtohhmtggrshhtrdhnvghtpdhrtghpthhtohepfhhinhiivghljhesghhmrghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhgvghnvghrrghlsehpohhsthhgrhgvshhqlhdrohhrghdprhgtphhtthhopehtghhlsehsshhsrdhpghhhrdhprgdruhhs X-Xfinity-VMeta: sc=-100.00;st=legit Received: from jsievers.enova.com (localhost [127.0.0.1]) by jsievers.comcast.net (Postfix) with ESMTP id 1EB3F26005A; Fri, 5 Mar 2021 17:44:57 -0600 (CST) From: Jerry Sievers To: Tom Lane Cc: Jeremy Finzel , Postgres General Subject: Re: Unkillable processes creating millions of tiny temp files References: <1517658.1614983320@sss.pgh.pa.us> Date: Fri, 05 Mar 2021 17:44:57 -0600 In-Reply-To: <1517658.1614983320@sss.pgh.pa.us> (Tom Lane's message of "Fri, 05 Mar 2021 17:28:40 -0500") Message-ID: <875z25jhc6.fsf@jsievers.enova.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Tom, thx for the quick response and a few remarks below... I work at the same site that Jeremy does and we're both looking at this today. Tom Lane writes: > Jeremy Finzel writes: > >> We are running postgres 11.9 (were running 11.7 prior to recent restart) on >> a large db (10s of TB) with 5 or 6 tablespaces and 1000s of tables/indexes. Actually it's v11.11 now, but in any case, the issue was evident before and after the minor version update. > >> Within the past few days we have started to see a few queries running for >> over 8 hours which we then attempt to terminate, but will not terminate. >> These queries are also generating hundreds of thousands of tiny/empty temp >> files. In fact, before the restart there were over 23 million files in >> pg_tmp which were removed. We also have verified no server settings have >> changed for at least a couple weeks, well before this issue started >> happening only in the past few days. > > Hm. For the query plan you show, I think the only plausible explanation > for using temp files is that a hash join's hash table is exceeding > work_mem so it's spilling batches of tuples to disk. With some bad > luck those could be small not large. But I don't see anything in > our commit logs between 11.7 and 11.9 that looks like it would have > affected any of that behavior. (There were some changes to code > governing temp-file tablespace selection, but that could only affect > where the files get put not how big they are.) So I doubt that this > can be blamed on the update, especially since if I read you correctly > it didn't start happening immediately after the update. It started happening a couple days ago for no obvious reason, so bad stats are one of my thrtheories and w'ere running a defensive analyze through the entire system to rule it out. > I'm wondering about changes in table statistics possibly causing a > poorly-chosen change in the hashing parameters. What have you got > work_mem set to? Can you comment on whether the estimated rowcounts work_mem 1G. We are not aware of the client overriding this in their code, but it's possible. > shown in the query plan are accurate? Does manually ANALYZE'ing the > tables used in the query change anything? These other points are still under investigation. > > 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. 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. I'm going to leave it a alone a a while longer before taking action. Thanks again > regards, tom lane > > > -- Jerry Sievers Postgres DBA/Development Consulting e: postgres.consulting@comcast.net