Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uSR8g-007Uhu-Mx for pgsql-hackers@arkaria.postgresql.org; Fri, 20 Jun 2025 02:05:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uSR8d-00G65a-7z for pgsql-hackers@arkaria.postgresql.org; Fri, 20 Jun 2025 02:05:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uSR8c-00G65S-T8 for pgsql-hackers@lists.postgresql.org; Fri, 20 Jun 2025 02:05:55 +0000 Received: from fhigh-b3-smtp.messagingengine.com ([202.12.124.154]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uSR8b-0032xJ-0p for pgsql-hackers@postgresql.org; Fri, 20 Jun 2025 02:05:55 +0000 Received: from phl-compute-06.internal (phl-compute-06.phl.internal [10.202.2.46]) by mailfhigh.stl.internal (Postfix) with ESMTP id B0EC42540160; Thu, 19 Jun 2025 22:05:51 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Thu, 19 Jun 2025 22:05:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1750385151; x=1750471551; bh=vdP6ybj/a7 mhQJNYRPcj9V0j23D7OeI+5Az4BKW6VIY=; b=T3zu9y/bQc3jaq9yqub5LH2hxf 2EH8b1DALRRJSgh0jUlzfGlPHa21kKG1tDm19lckVNaiQwh4gzyNwYf7ZitOwBvs FfIiI1wxcRFosVrYrqVcj1dFUQcLaFwUvu41bx2Y/GtP7orI3ri8fS6ooWVcch0t 8RL/6xhxE3wqCuhjHkgNW2pB+woP4EzVi0G7rH59q1QLbdkplOjXUYjjmCx3mDFz gsqyvOg9bjErkpz/WclNOFkH9QFsfGima7mxsyDCdxJiL53a2yo+z1PJWfeej9/I 4eyiMb9IlrMkSymf1hxA54714qCKOoihioOlHTYTdYavmZFT6f1/MyRKJJdA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1750385151; x=1750471551; bh=vdP6ybj/a7mhQJNYRPcj9V0j23D7OeI+5Az 4BKW6VIY=; b=kXu81VnEMt3goWs6jTWBLSfO2EiVf7m1y3SJ6Bwtz28ZxZSL/P/ n0PS9o4vrrBma0O6TTUgYd+zwBo6JtCunrNzqaGMQs8uNSUrhJCHdKFyInW4RiDN h3XjKhRDP2ZQ5G0HhWu8/2aLsFNqlCmQgIjkypXkBlLX2rWcLaxryAcBFd0D3tCo aI0MEPkzhQ77MrN0S84zJodCPk9/6tQPaFRpnH4NGHBIHt00U2YDFAqRaqyoQaH8 X8siTl92WS2Huwc34GZdxwENG8QK0eFRvNzjk94ZBPi7hF5FNBvyXndikxyMhxMh WJFVtlHnmLPK6Yk0vRxDeqTe6G/11E6kXcw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtddvgdejudeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceurghi lhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrhhluc fvnfffucdljedtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredttddvnecu hfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqhhuih gvrhdrgiihiieqnecuggftrfgrthhtvghrnhepteelieefudffhffhtdetleeggeegfffh keeuveetiefgudduvedutefggeeivdejnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihiidpnhgs pghrtghpthhtohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepnhgrthhhrg hnuggsohhsshgrrhhtsehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhqlhdqhhgr tghkvghrshesphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 19 Jun 2025 22:05:50 -0400 (EDT) Date: Fri, 20 Jun 2025 11:05:37 +0900 From: Michael Paquier To: Nathan Bossart Cc: pgsql-hackers@postgresql.org Subject: Re: problems with toast.* reloptions Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="1CL3EhlQ3DIUOrCQ" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --1CL3EhlQ3DIUOrCQ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jun 19, 2025 at 03:20:27PM -0500, Nathan Bossart wrote: > While investigating problems caused by vacuum_rel() scribbling on its > VacuumParams argument [0], I noticed some other interesting bugs with the > toast.* reloption code. Note that the documentation for the reloptions h= as > the following line: >=20 > If a table parameter value is set and the equivalent toast. parameter > is not, the TOAST table will use the table's parameter value. >=20 > The problems I found are as follows: >=20 > * vacuum_rel() does not look up the main relation's reloptions when > processing a TOAST table, which is a problem for manual VACUUMs. The > aforementioned bug [0] causes you to sometimes get the expected behavior > (because the parameters are overridden before recursing to TOAST), but > fixing that bug makes that accidental behavior go away. Are you referring to the case of a VACUUM pg_toast.pg_toast_NNN? I'm not sure that we really need to care about looking up at the parent relation in this case. It sounds to me that the intention of this paragraph is for the case where the TOAST table is treated as a secondary table, not when the TOAST table is directly vacuumed. Perhaps the wording of the docs should be improved that this does not happen if vacuuming directly a TOAST table. > * For autovacuum, the main table's reloptions are only used if the TOAST > table has no reloptions set. So, if your relation has > autovacuum_vacuum_threshold and toast.vacuum_index_cleanup set, the main > relation's autovacuum_vacuum_threshold setting won't be used for the > TOAST table. [.. /me double-checks the code .. ] So we combine the options in do_autovacuum() with the two-pass logic to gather the relation OIDs, then apply relation_needs_vacanalyze(). That looks like an old issue, that cannot be solved as long as we rely on the relopts to be an all-or-nothing thing when assigning the individual values for the TOAST relation. Oops. > * Even when the preceding point doesn't apply, autovacuum doesn't use the > main relation's setting for some parameters (e.g., vacuum_truncate). > Instead, it leaves them uninitialized and expects vacuum_rel() to fill > them in. This is a problem because, as mentioned earlier, vacuum_rel() > doesn't consult the main relation's reloptions either. Relying on vacuum_rel() sounds like a bad idea if we can avoid that, still perhaps that's OK as long as we don't use a pointer to the VacuumParams and keep the updates to the value of vacuum_rel() local inside the routine. > I think we need to do something like the following to fix this: >=20 > * Teach autovacuum to combine the TOAST reloptions with the main relation= 's > when processing TOAST tables (with the toast.* ones winning if both are > set). >=20 > * Teach autovacuum to resolve reloptions for parameters like > vacuum_truncate instead of relying on vacuum_rel() to fill it in. These two points make sense here, yes. > * Have vacuum_rel() send the main relation's reloptions when recursing to > the TOAST table so that we can combine them there, too. For the case of a manual VACUUM on the main table, where the TOAST table is treated as a secondary citizen, that makes sense as well, yes. > This doesn't fix VACUUM against a TOAST table directly (e.g., VACUUM > pg_toast.pg_toast_5432), but that might not be too important because > (PROCESS_TOAST TRUE) is the main supported way to vacuum a TOAST table. = If > we did want to fix that, though, I think we'd have to teach vacuum_rel() = or > the relcache to look up the reloptions for the main relation. This one does not sound that important to me for the case of manual VACUUM case directly done on a TOAST table. If you do that, the code kind of assumes that a TOAST table is actually a "main" relation that has no TOAST table. That should keep the code simpler, because we would not need to look at what the parent relation holds when deciding which options to use in ExecVacuum(). The autovacuum case is different, as TOAST relations are worked on as their own items rather than being secondary relations of the main tables. -- Michael --1CL3EhlQ3DIUOrCQ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmhUwfEACgkQnvQgOdby QH3Z8g//eH+q+gv2p+edzewLT6yi+1Mv+ngnDNQ+TFYadMhLl9M12Px4WXb1ljTE r6PZPlCtictBJtTnDiaB8/q9ZPi3g9KBgFATWT6jWsoWrorLtby6OW8aVZSK0zLz jN1JKHu2W7WHsKUeIQ7slMNdZahtp43WvTvYYjVSt/Zb5lUSBCDW/PROnv34/TQ1 iwfkKhnx7arZgtnC+5ljleyX/t7cjtn8e2iebZzcg4we7im8fQuRhupDuBenI4kv aGzBqZNETr3hgcVdzcC1dR2v5+P++3IMvaYA7y5jaWH2CHBV3rVRxCA1JW8ZWjCL PtXlwRiix/LA7JUA5MbQFFcrGzp5KkGsaQGWSAoENyMt7pkCzPprAo6Onpgqo1xb 43L2uvLxS85wZgCNeW1B8eXuoOn364KGrDRh8MZ67AoWQf07Al/tAIRJ90w3/6jG rWIpgs+MHLqzNDmDEpvG7ADyJDJU2y1TCPZz5oEGOcWicnXmFDDWjF/uitr6Nt10 +nKCkA8B62twYyFMzUggDQIEWnFubmv/7PXf4wakB1oyIcy1fM+rihVKMmVOHCBg pMdnUosTwJ23a0pybOPSzsgVDbcMkhhm4qctrvHT2is7uEoaaqYQPQczMoneZZey g3u+nF8oR+9yrF0dS4lIkIgBAh2cGVwoYSJteN2vhO9blEJ2E/E= =rWCz -----END PGP SIGNATURE----- --1CL3EhlQ3DIUOrCQ--