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 1mLXLe-0007Wi-Sm for pgsql-general@arkaria.postgresql.org; Wed, 01 Sep 2021 21:00:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mLXLd-0006vB-HO for pgsql-general@arkaria.postgresql.org; Wed, 01 Sep 2021 21:00:41 +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 1mLXLc-0006v3-JU for pgsql-general@lists.postgresql.org; Wed, 01 Sep 2021 21:00:41 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mLXLY-0005T3-Rw for pgsql-general@lists.postgresql.org; Wed, 01 Sep 2021 21:00:40 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 24DCC5C0103; Wed, 1 Sep 2021 17:00:33 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 01 Sep 2021 17:00:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=e2xHDTWGpSyGaaWiXdgHWW+iGyCMOhLIFCb/oVECNag=; b=FXTTMsvP WUXn6/3SPPTFXFgi/ix1r30BxJb+eqEcrKCua2JlWpTxFbJcvSnvfybueKnaU2/v R7O1g4zsjnm6Tp9/gobyS0ON/zNQGFvZD3ljo0r4byrKdDfKV/7fHRJ83kZiEStl 8FPyvg+3sTnLmsCZzTPdMb+xnY8ZDvaDMeKKs0A2suI7WCbLnCMNVTyILOF7BkPH xByQBQrShg0T8S5RJuQrRGL2zU4FuCQ1dsKOc+rkETVgQfMZ9qzt2n0cNv4dfeAE enQ6XkTHcxDBCZ1zzqTXpLmrvVLdB0I9Yg3RkHSCwD+54J6/vWQXcAbPN0lmGiw4 8wAuyA65RQKFlw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddruddvfedgudehgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvuffkgggtugfgjgesthekredttddtjeenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnheptedukeejiefgheevtdffkeehleegieehueetleffveff keevgfetudevveelieeunecuffhomhgrihhnpehpohhsthhgrhdrvghsnecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgvsegr lhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 1 Sep 2021 17:00:32 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id AB9802A0817; Wed, 1 Sep 2021 17:00:29 -0400 (-04) Date: Wed, 1 Sep 2021 17:00:29 -0400 From: Alvaro Herrera To: Matthew Tice Cc: pgsql-general@lists.postgresql.org Subject: Re: datfrozenxid not dropping after vacuum Message-ID: <202109012100.su7q5t3e3zbj@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021-Sep-01, Matthew Tice wrote: [ problem table is pg_database ] > My primary, read/write database is Postgresql 10.4 (CentOS 7) while my > standby databases have been patched to 10.17. Hmm, I think there was a bug in the early 10.x versions where advancing the xid age of shared tables would not work correctly for some reason ... Ah yes, this was fixed in 10.5, a mere three years ago: Author: Andres Freund Branch: master Release: REL_11_BR [a54e1f158] 2018-06-12 11:13:21 -0700 Branch: REL_10_STABLE Release: REL_10_5 [2ce64caaf] 2018-06-12 11:13:21 -0700 Branch: REL9_6_STABLE Release: REL9_6_10 [6a46aba1c] 2018-06-12 11:13:21 -0700 Branch: REL9_5_STABLE Release: REL9_5_14 [14b3ec6f3] 2018-06-12 11:13:21 -0700 Branch: REL9_4_STABLE Release: REL9_4_19 [817f9f9a8] 2018-06-12 11:13:22 -0700 Branch: REL9_3_STABLE Release: REL9_3_24 [9b9b622b2] 2018-06-12 11:13:22 -0700 Fix bugs in vacuum of shared rels, by keeping their relcache entries current. When vacuum processes a relation it uses the corresponding relcache entry's relfrozenxid / relminmxid as a cutoff for when to remove tuples etc. Unfortunately for nailed relations (i.e. critical system catalogs) bugs could frequently lead to the corresponding relcache entry being stale. This set of bugs could cause actual data corruption as vacuum would potentially not remove the correct row versions, potentially reviving them at a later point. After 699bf7d05c some corruptions in this vein were prevented, but the additional error checks could also trigger spuriously. Examples of such errors are: ERROR: found xmin ... from before relfrozenxid ... and ERROR: found multixact ... from before relminmxid ... To be caused by this bug the errors have to occur on system catalog tables. The two bugs are: 1) Invalidations for nailed relations were ignored, based on the theory that the relcache entry for such tables doesn't change. Which is largely true, except for fields like relfrozenxid etc. This means that changes to relations vacuumed in other sessions weren't picked up by already existing sessions. Luckily autovacuum doesn't have particularly longrunning sessions. 2) For shared *and* nailed relations, the shared relcache init file was never invalidated while running. That means that for such tables (e.g. pg_authid, pg_database) it's not just already existing sessions that are affected, but even new connections are as well. That explains why the reports usually were about pg_authid et. al. To fix 1), revalidate the rd_rel portion of a relcache entry when invalid. This implies a bit of extra complexity to deal with bootstrapping, but it's not too bad. The fix for 2) is simpler, simply always remove both the shared and local init files. Author: Andres Freund Reviewed-By: Alvaro Herrera Discussion: https://postgr.es/m/20180525203736.crkbg36muzxrjj5e@alap3.anarazel.de https://postgr.es/m/CAMa1XUhKSJd98JW4o9StWPrfS=11bPgG+_GDMxe25TvUY4Sugg@mail.gmail.com https://postgr.es/m/CAKMFJucqbuoDRfxPDX39WhA3vJyxweRg_zDVXzncr6+5wOguWA@mail.gmail.com https://postgr.es/m/CAGewt-ujGpMLQ09gXcUFMZaZsGJC98VXHEFbF-tpPB0fB13K+A@mail.gmail.com Backpatch: 9.3- -- Álvaro Herrera 39°49'30"S 73°17'W "El número de instalaciones de UNIX se ha elevado a 10, y se espera que este número aumente" (UPM, 1972)