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.89) (envelope-from ) id 1hZPBy-0007mN-EX for pgsql-hackers@arkaria.postgresql.org; Sat, 08 Jun 2019 00:26:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hZPBx-0008Aq-9Y for pgsql-hackers@arkaria.postgresql.org; Sat, 08 Jun 2019 00:26:41 +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 1hZPBw-00082n-50 for pgsql-hackers@lists.postgresql.org; Sat, 08 Jun 2019 00:26:41 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hZPBt-0007aO-3v for pgsql-hackers@lists.postgresql.org; Sat, 08 Jun 2019 00:26:39 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 9D2C12224C; Fri, 7 Jun 2019 20:26:35 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Fri, 07 Jun 2019 20:26:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=doXBFhc4O73Lhgef3GcnLjzXg5B ZOOvtVuepydudS74=; b=gEVMzGL9tA2WaGTsR3iRISSdVZsz2GlWyxaPtn215nx BUIDxdnY6kJ5Pnn3tnT+VBbHL4TFNMFrXyU33r2pn7Pjj9O8dzN8dq/hSVRgtbzV D8oq5WyqpswBvrThBqBUJ7wkQbqEzgSB4XvckCnNnGTvVOLxRavtHZcqGVCx715i CXIaII9kyNv9wCcezoJjOXbwBmm38CZIGwcmwYghkJZOVX/2kKziAprRwyhOfUha gIIpJkDxpqe1Yi+p+lcSmjjdo5La9crzZmIqqmlLlq9F220iuaRvzkQf/zQwKR4p bMD92ccvXSlvnVY2vS6lY36RvI6jLrjtx3YaH01jUTA== 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=doXBFh c4O73Lhgef3GcnLjzXg5BZOOvtVuepydudS74=; b=o+OBq+3HvE3SsPetCL7oWJ jwz0hc1CFN+JKZeACi31z9JJ6BtX9PzkD0DmJctCJQ6c52/6z5bE6LNLKsCZzUSK kATHzhjObqXUCm2o2oQ76OK+VVgHQUqUXFz6DOrswYUAaKDKfgqlf7+pPGOwvU1v 8V/BGKdznF9rRO6KCmMTxPRH87UJTpPqD+ZC/L1KQe/2ua0dE6FPp+1xS89hB2kw h+FFz3BfQ1v1gnOvg6/HkM5FQEWQmHPs9//Luw9/nnFK+EECJKKUTXEJ2cC/zfUb 1ROCSiRFaIvza+ko1NTKpVgTAFIjiDz+UR6iEnHDw2q8MMfU8B/FRwbcAWN8IwGg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrudegjedgfeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeetnhgurhgv shcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucfkphepie ejrdduiedtrddvudekrddvfeejnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrnhgurhgv shesrghnrghrrgiivghlrdguvgenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from intern.anarazel.de (c-67-160-218-237.hsd1.ca.comcast.net [67.160.218.237]) by mail.messagingengine.com (Postfix) with ESMTPA id 920468005B; Fri, 7 Jun 2019 20:26:34 -0400 (EDT) Date: Fri, 7 Jun 2019 17:26:32 -0700 From: Andres Freund To: Michael Paquier Cc: Thierry Husson , Robert Haas , Tom Lane , pgsql-hackers@lists.postgresql.org Subject: Re: Temp table handling after anti-wraparound shutdown (Was: BUG #15840) Message-ID: <20190608002632.ptuvc6tbffjhlsgi@alap3.anarazel.de> References: <15840-06c9565bfd8099f6@postgresql.org> <20190607190231.6psb6w3bvlod7lvk@alap3.anarazel.de> <20190607145911.Horde.MKizKAnShw4nKEYGDUC2M-T@webmail.iciel.com> <20190607201002.cado5goe3rcup43n@alap3.anarazel.de> <20190607164027.Horde._egTUMJMTDBA4f31sPYgl_J@webmail.iciel.com> <20190607225843.z73jqqyy6hhc6qnp@alap3.anarazel.de> <20190607235937.GA1590@paquier.xyz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190607235937.GA1590@paquier.xyz> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2019-06-08 08:59:37 +0900, Michael Paquier wrote: > On Fri, Jun 07, 2019 at 03:58:43PM -0700, Andres Freund wrote: > > Do we need to move the orphan temp cleanup code into database vacuums or > > such? > > When entering into the vacuum() code path for an autovacuum, only one > relation at a time is processed, and we have prior that extra > processing related to toast relations when selecting the relations to > work on, or potentially delete orphaned temp tables. For a manual > vacuum, we finish by deciding which relation to process in > get_all_vacuum_rels(), so the localized processing is a bit different > than what's done in do_autovacuum() when scanning pg_class for > relations. Yea, I know. I didn't mean that we should only handle orphan cleanup only within database wide vacuums, just *also* there. ISTM that'd mean that at least some of the code ought to be in vacuum.c, and then also called by autovacuum.c. > Technically, I think that it would work to give up on the gathering of > the orphaned OIDs in a gathering and let them be gathered in the list > of items to vacuum, and then put the deletion logic down to > vacuum_rel(). I don't think it makes much sense to go there. The API would probably look pretty bad. I was more thinking that we'd move the check for orphaned-ness into a separate function (maybe IsOrphanedRelation()), and move the code to drop orphan relations into a separate function (maybe DropOrphanRelations()). That'd limit the amount of code duplication for doing this both in autovacuum and all-database vacuums quite considerably. A more aggressive approach would be to teach vac_update_datfrozenxid() to ignore orphaned temp tables - perhaps even by heap_inplace'ing an orphaned table's relfrozenxid/relminmxid with InvalidTransactionId. We'd not want to do that in do_autovacuum() - otherwise the schema won't get cleaned up, but for database widevacuums that seems like it could be good approach. Random observation while re-reading this code: Having do_autovacuum() and ExecVacuum() both go through vacuum() seems like it adds too much complexity to be worth it. Like half of the file is only concerned with checks related to that. Greetings, Andres Freund