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 1uSLkT-006SAg-OD for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Jun 2025 20:20:37 +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 1uSLkQ-00EZPV-VK for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Jun 2025 20:20:35 +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 1uSLkQ-00EZPM-Jy for pgsql-hackers@lists.postgresql.org; Thu, 19 Jun 2025 20:20:35 +0000 Received: from mail-io1-xd2a.google.com ([2607:f8b0:4864:20::d2a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uSLkO-0030MG-2O for pgsql-hackers@postgresql.org; Thu, 19 Jun 2025 20:20:34 +0000 Received: by mail-io1-xd2a.google.com with SMTP id ca18e2360f4ac-86cfc1b6dcaso30467539f.0 for ; Thu, 19 Jun 2025 13:20:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750364430; x=1750969230; darn=postgresql.org; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=+CR2UBwlqHnCXa1PH6615RNo0Mwro4jp9qF8ahOAJn4=; b=Qmo5ZyXSQE387CKla4tKTnynvZYkfk4lLHHxmPQP48p4EVV6ATfwT2bDm57gh5upeZ rvvBtAWcQNyJDgx/Ya+GwtI6GQBRaCvNh+Uv0Pg1cxeNohH00pf5Cn0R8E/mxjcY3hH2 JPbAhEtCK7yoGlLx5MxKPES9U5lsH5O53NH0o8dCYE67/fqdDOdSdcsMM5WXQI/5KPhg LJRUW2gAWEnURot9PjwXePqx3EaoIIWujASnrOF2VfP+FVPe0vf2lrF3k2bLjOERnumh kAT+N9z28hGmx2mR6lOx+8nM4M5jeM0WOQEX1sfiO9H7SAw89xoBGimRXhSx2CHZ3ijW cgmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750364430; x=1750969230; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+CR2UBwlqHnCXa1PH6615RNo0Mwro4jp9qF8ahOAJn4=; b=ImsD426spNhWLPCIRQjY6OMKqkS9R/aZlYfbqph6Ucl8HN+1nt/zLyc6sTEAYopFva XOnczbb5ZfYXT59tmrdfpzGtpUOGQBqjA5ckoUIE5YgZ/TiZyz8p+BJpZXxqFvEi7pvY FD+bO6fSRr9O7U5rvP/+zzvQf3pleq2OYIG0wyWJbplluZEpKI2sQdJmQ2y0Ve3MIOB3 qN6heFRJn21U1Um+EeK8uos2Qi5m0fH4r2+ivdc3MWKfVdbMBmoYA8oupCr+9mr0U1EN Ao+NXIkjki/4y1Ul4juOcs0YrnMpkYpgDW6rQU33u5zU4aQATP5kpCJrULIOaQkY8WKT 4aYQ== X-Gm-Message-State: AOJu0YwmuKVsuwrytIFeYItVo0lwk4c7GUPZ2abO7x5gUk8R1UTs77IF IP9BD7xn10kRGbgqkEUjrcEJbacGlK8E11Yv3VIbXZnrrdBy/9d/9XyIcWiWfA== X-Gm-Gg: ASbGnctYPg07zd4zy8HB5Wc/8ewAJphQ8ajuAiU/VcVvI2wvs9NN+yCcJ/mWLLSCbai zgqTCw2oQV1+vAlXuxOWOTxB2auWDkH583i/dbdtHjYDdMgvaDimlmuojDEA/Nym19pcw855XCi WB5Y10KvtxHDZygoAqchSpqVgcVNIA2jneFjaRFw0TLMtkxqCTGGj34eJeKsh6KsjmAgOP3mtkW 0+K5owBCHNyAWeap29F6NGftQRCQq3QFQqvBLmWVhCrWQlSikYak0GqTOvrPrB3odm6H+4q/AED GqaBsLi4HyFD4T9me/BMENjZe0633/ARPxmjctPItiVQxAYb+wBAOIXx3LFk4iJisTwMctSwXPW /SVSYfoDb+Pa1cB+RzJNEztIbbkkfNaYt0UJISXyqD5ex3Z9xT0BL X-Google-Smtp-Source: AGHT+IFkjP7NMdu7bt0tqzJzv/XHlRk5OgrsF1EuKwW7KTsXg253x0l5QqgbKLz2q5zWtxnyU6ctCA== X-Received: by 2002:a05:6602:60c5:b0:876:1c5e:8c50 with SMTP id ca18e2360f4ac-8762d1e8bf4mr16826839f.7.1750364430242; Thu, 19 Jun 2025 13:20:30 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id ca18e2360f4ac-8762b6a3764sm9093339f.25.2025.06.19.13.20.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jun 2025 13:20:29 -0700 (PDT) Date: Thu, 19 Jun 2025 15:20:27 -0500 From: Nathan Bossart To: pgsql-hackers@postgresql.org Subject: problems with toast.* reloptions Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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 has the following line: If a table parameter value is set and the equivalent toast. parameter is not, the TOAST table will use the table's parameter value. The problems I found are as follows: * 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. * 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. * 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. I think we need to do something like the following to fix this: * 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). * Teach autovacuum to resolve reloptions for parameters like vacuum_truncate instead of relying on vacuum_rel() to fill it in. * Have vacuum_rel() send the main relation's reloptions when recursing to the TOAST table so that we can combine them there, too. 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. Thoughts? [0] https://postgr.es/m/flat/CAGRkXqTo%2BaK%3DGTy5pSc-9cy8H2F2TJvcrZ-zXEiNJj93np1UUw%40mail.gmail.com -- nathan