Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jGc4w-0005Zc-L5 for pgsql-general@arkaria.postgresql.org; Tue, 24 Mar 2020 05:26:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jGc4v-0000sj-ES for pgsql-general@arkaria.postgresql.org; Tue, 24 Mar 2020 05:26:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jGc4v-0000sc-4G for pgsql-general@lists.postgresql.org; Tue, 24 Mar 2020 05:26:17 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jGc4r-0008Ug-TC for pgsql-general@lists.postgresql.org; Tue, 24 Mar 2020 05:26:16 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 96C9A5C01F8; Tue, 24 Mar 2020 01:26:11 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Tue, 24 Mar 2020 01:26:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=5GJgrgDlNbJUuZPDcaPJWiAxITI bHKBACL8VH/2njjA=; b=eKy4sUz3WDjLKpdhvTSqLxboSIVj3W5T5jRj7DwrPfp kUHtOlXtt0Lsq1uraWZ2kDdq6DNGzxakyQ/J2dzbljzGW+g2NqLXnW0BTcqo5NKw ZBLVkiKvTZzG6Oxbe5DzFlDuR2SxqgXE7IjmX56O7RpxhYG1aFpYp0xaSUH6rtOL /byOIOBrjbQUtbQrebeUed+v3FR9pKOZXH5tccEib0bearbXIrcQxoxUB69xjW6U 38BZU+/rx9KJPUl3eJ4FICwdNP2Y0BXc5TbDkC34PO1BkUmxZyKkV/wQK6IOWxIc a9l3VpGfKlgk+6B4V4jcZn0zq6VbxWm/+LXIMje1pqg== 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=5GJgrg DlNbJUuZPDcaPJWiAxITIbHKBACL8VH/2njjA=; b=pLpJw+pSI5hCbqTvG1iQKX ZbgPzFL2MhVJZOd6ByvCAo0hL9ArDjw5cnnrnoe/IuUAhqC08I0zmVd7sXsjdqkJ 63rW+KacVPtjQtI0ZoTMIQzIFCHKE7JuqSxkViZ9KBcUQioR2QE52Jo4vVJvpf2m 4UC9ZJmhI3qpTt3ctMXdtMpSFNUXram9xCIA/2OwdwIjMKDMlzfPjx8ItQWSaB7T FvGvRNQf/cmoZQUoT/Qtba1YmSYXknSBTki3dWmaHseKR5leSn6jfx90U5BFtLFt A2o6IL18xGVzf1xENNu4KLKr7M78OFR13SnubS0INHcho4HxNwuDEAmbXdv0S8iA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrudegledgkedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdlfeehmdenucfjughrpeffhffvuffkfhggtggujgesghdtreertddt vdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprg hquhhivghrrdighiiiqeenucffohhmrghinhepghhithhhuhgsrdgtohhmnecukfhppedu uddurddutddvrddukedtrddukeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrg hmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihii X-ME-Proxy: Received: from paquier.xyz (ee0822lan1.rev.em-net.ne.jp [111.102.180.185]) by mail.messagingengine.com (Postfix) with ESMTPA id 730C53280063; Tue, 24 Mar 2020 01:26:09 -0400 (EDT) Date: Tue, 24 Mar 2020 14:26:06 +0900 From: Michael Paquier To: Andres Freund Cc: Julien Rouhaud , Justin King , pgsql-general@lists.postgresql.org, kgrittn@gmail.com Subject: Re: PG12 autovac issues Message-ID: <20200324052606.GE1836@paquier.xyz> References: <20200319223520.2mnjt6l3yybgnd77@alap3.anarazel.de> <20200319235626.wz4b57hbhuuy4w7j@alap3.anarazel.de> <20200320190317.gdxwzexdfutymqs6@alap3.anarazel.de> <20200323152247.GB52612@nol> <20200323162303.s7ay5hjdvimtkz6u@alap3.anarazel.de> <20200323194725.GC52612@nol> <20200323200051.qzyqvnips7o3ai4g@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="/QKKmeG/X/bPShih" Content-Disposition: inline In-Reply-To: <20200323200051.qzyqvnips7o3ai4g@alap3.anarazel.de> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --/QKKmeG/X/bPShih Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Mar 23, 2020 at 01:00:51PM -0700, Andres Freund wrote: > On 2020-03-23 20:47:25 +0100, Julien Rouhaud wrote: >>> - relfrozenxid, age(relfrozenxid) for the oldest table in the oldest da= tabase >>> SELECT oid::regclass, age(relfrozenxid), relfrozenxid FROM pg_class W= HERE relfrozenxid <> 0 ORDER BY age(relfrozenxid) DESC LIMIT 1; >>=20 >> The vm has been trashed since, and I don't have that level of detail ava= ilable >> in the gathered stats unfortunately (and the available information I hav= e is a >> little bit messy, sorry for that). >>=20 >>> - Oldest backend xmin >>> SELECT pid, backend_xmin, age(backend_xmin) FROM pg_stat_activity WHE= RE backend_xmin <> 0 ORDER BY age(backend_xmin) DESC LIMIT 3; >>> - oldest replication xmin: >>> SELECT pid, backend_xmin, age(backend_xmin) FROM pg_stat_replication = WHERE backend_xmin <> 0 ORDER BY age(backend_xmin) DESC LIMIT 3; >>> - oldest slot xmin: >>> SELECT slot_name, xmin, age(xmin), catalog_xmin, age(catalog_xmin) FR= OM pg_replication_slots WHERE xmin <> 0 OR catalog_xmin <> 0 ORDER BY great= est(age(xmin), age(catalog_xmin)) DESC LIMIT 3; >>> - oldest prepared transaction (unfortunately xmin not available) >>> SELECT gid, database, transaction FROM pg_prepared_xacts ORDER BY age= (transaction) LIMIT 3; >>=20 >> I have output from this query: https://github.com/OPMDG/check_pgactivity= /blob/oldest_xmin/check_pgactivity#L5669-L5732 >> (which may be dumb). Here are the non-null rows after 8AM GMT+1: This stuff does not use 2PC and logical slots (there is one physical slot for a WAL archiver), but we got a dump of pg_stat_activity. Grepping more info about the evolution of pg_database and pg_class is on our list. > Could you share what the config of the server was? Nothing really fancy: - autovacuum_vacuum_cost_delay to 2ms (default of v12, but we used it in v11 as well). - autovacuum_naptime =3D 15s - autovacuum_max_workers =3D 6 - log_autovacuum_min_duration =3D 0 >>> In that case you'd likely see DEBUG1 output, right? Did you try running >>> with that? >>=20 >> That's unfortunately not an option, as while the issue is reproducible, = it >> happens after roughly 16h with an average of 6.5ktps, and we definitely = don't >> have enough disk space for that amount of logs. We'll try next time wit= h a >> recompiled version with the DEBUG1 promoted to WARNING, and maybe other = elog. >=20 > You wouldn't need to run it with DEBUG1 the whole time, you could just > change the config and reload config once you hit the issue. Sure, though it would reduce the window when the cluster is still up and running. One option that we have is just to increase the elevel =66rom DEBUG1 to WARNING for the log added in 2aa6e33 to keep the amount of logs reduced without losing information, and we have no issue to do runs with custom patches. >> Not for now, because it's hard to be around for the ~ 90min interval the= system >> stays alive after atuvacuum get stuck, especially since it's a weekend b= ench. Yeah, our room is very limited here. I would likely not ne able to do that, or I would just get very lucky with my timezone. Not sure for Julien. >>> It sounds like what might be happening is that you have something >>> holding back the "oldest needed transaction" horizon. Before >>> 2aa6e331ead7, if the xmin horizon hasn't increased, there'd be repeated >>> vacuums unable to increase the horizon, but afterwards they'll all >>> immediately exit without any messages. >>=20 >> The xmin horizon is increasing AFAICS. Grepping the autovacuum logs, I = can see >> for the 08:00 AM UTC - 08:59 AM UTC interval the oldest xmin going from >> 200069684 to 210363848. E.g.: >=20 > Which database is this on? In this case this was the database used by the application, FWIW. But I can see from those logs that it kept increasing for all the other databases, like postgres or template1 when this set of aggressive jobs happened. >> 266621:2020-03-14 08:49:59.945 UTC LOG: automatic aggressive vacuum to = prevent wraparound of table "pg_toast.pg_toast_27712": index scans: 0 >> 266622- pages: 0 removed, 0 remain, 0 skipped due to pins, 0 skipped fro= zen >> 266623- tuples: 0 removed, 0 remain, 0 are dead but not yet removable, o= ldest xmin: 209635953 >> [...] >=20 > Do you have any non-toast ones? Yep, this includes catalogs and normal tables, based on the logs all the relations triggered aggressive and anti-wraparound jobs. >>> I wonder if what might be happening is that we're somehow missed/failed >>> to update relfrozenxid and/or datfrozenxid. If you manually vacuum some >>> table in the oldest database, but that is *NOT* the oldest table itself, >>> does the problem "resolve" itself? >>=20 >> I'll also add pg_class snapshot for next time we run the bench. I'm not= sure >> if we'll be able to catch the 1h45 interval when the system stays alive >> after the issue though. >=20 > Could you just script something to stop the benchmark once the disk is > 90% full or so? Hmm. I think that this one is possible still tricky. There are some alarms in place in this system. > Did you see any errors / fatals around the time autovacuum stopped > working? Before going rogue (we are not sure if autovacuum didn't launch any workers or if the workers were spawned and exited early as we did not capture any worker information in pg_stat_activity), we saw a bunch of aggressive wraparound jobs. Even after that, we have traces in the logs of one autovacuum analyze happening at equal interval of time (17 minutes) on one single table, which is... Er... uncommon to say the least. -- Michael --/QKKmeG/X/bPShih Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAl55me4ACgkQnvQgOdby QH1OjBAAi8R22N8D94CkFoD4KxT306P2qajVTRmFMPi6v63nngp/AQ9dwlCU4IHz zr/O1StEKgel3qimPQK2uAGhL9Tth4A/t3WSrz5U8OIK9FZ6QY63hnd9NBTTmO6e VurussiMZ5Aj9P0r+EZV+QllLeeB3X3VW+vx5I/LgsXXmE9U9x7aWbWNXqRtkKfW beKa4yQ3NIPBooNBVc59eY4/8DUP4qT3UDHn+0YqDnf+diy/N3eXh6P9P/WszW8J a90gmRlKpCbZBhg4E4ODdNt740Eq25YPdM1i+FK2wXb7JomsChg3KFH1ZU4iecg6 JrRNxGGiozggJgnd2zLqObfv5i0MA/rjXjn/6w5gQXxRVIz8CEX2VuOdmJ4PLhtG +8oTYsXvkQjfG7QcRDqlI7vtK0WZWEwgR0751zqsyIRfDjrlh9M4YVGYT0XSqVjF euJiisge+pmmjp6y2EnjUqepw8Z7/UdYTttKIY2mH/QKTsRFSKnH8A215H2Zp7uA tQERsekaLx9GoW3xS6eKRGOg/whtqGHebs2pe3kYdE0NNDfR2DAE0iUoxOlU9pI3 qkTONsUDePLj/LmrI2UI6KD00DRg88bE/Ub9CXZ7jl3Ue86/VJq8jmgLjGpxtYkF BGfwxEqaivlnL0M2oxRWOOsakB8sf/5EDB+b0sPhsCo2LV70tLY= =FLDr -----END PGP SIGNATURE----- --/QKKmeG/X/bPShih--