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 1uScun-00AgVB-5P for pgsql-hackers@arkaria.postgresql.org; Fri, 20 Jun 2025 14:40:25 +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 1uScul-0024ek-7l for pgsql-hackers@arkaria.postgresql.org; Fri, 20 Jun 2025 14:40:23 +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 1uScuk-0024eb-UW for pgsql-hackers@lists.postgresql.org; Fri, 20 Jun 2025 14:40:23 +0000 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uScuj-0038k9-0T for pgsql-hackers@postgresql.org; Fri, 20 Jun 2025 14:40:23 +0000 Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-addcea380eeso332266566b.0 for ; Fri, 20 Jun 2025 07:40:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750430420; x=1751035220; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=kUvxAH2Pn3bkQ4rVPQMaWvKbPZqnlj5FdkQdqIB3Ifc=; b=Sf4hNSkS+ZwJJ2YxYiSEnT+SBH9SKB9pzoVQplANd7X80pU6YBAR3h4fJ1xZze+rX0 tYKNez5ydLxEmGm4222OYmtiVQoq4Dktn/fo6WHmXdyo6QgCoeoRK0dCKbVdHMk8KP7b Ol7YXZBhSRP22NyUzeamUgjFxYiS6Mk6vItUKrRnFCry0KDv8tp9GT3ZKBCD2RDMMMW3 8Ji7uqMHEGJTVNiKJnL7hnuEFGmO1q3nouRqh/OfkAgXdL+HrSbiR6Gn1VMx17NMASex dNSxuGjKJPvMEykQDlkiVMRci9WLZYcpUOONIGDfbJ95cOddlJGIs+E3r22yBQnA2kOR JArQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750430420; x=1751035220; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kUvxAH2Pn3bkQ4rVPQMaWvKbPZqnlj5FdkQdqIB3Ifc=; b=Y3skbKjRZx5AlxqaJx/VGArz0QWeg4ZWp283kVCqiBz3d67G9HN8OIJA0g3cIRwqXz sXoo9iveHhWG+Of2Hx0Ed1Oy5OlGwYiD7noUhhXHs4tv2O8KoCBJ7FohBX9hD/Pxwgex r79aTKeEctSSHR5HDrPf8mrRpBym4WJnjdacwXvQplGd5HqEk04CmUkm/bD1YjYF1+yl zFdvi28ONy4nMmCCmbKunvAipUe+xd/gVpI6Guh9vHDEX2U47FJK84pCwpPevzyzARLK X/CCKtSYdXmw4a+6wgvAXF9hpez9Caxu4VxXjShFfLIUrgedEv8lFQMIu12kc4Kui9xf k0Dg== X-Forwarded-Encrypted: i=1; AJvYcCVXhHLiC1NykYCUcUSBYpBGiU7763OSD9im2oqdGlXi8rXB/GCdG63i7F4KSDpamwg+HGiofHGptJavJSvn@postgresql.org X-Gm-Message-State: AOJu0Yxuwe/xVNBawuHHjFwO0no8/GBRdIFZfx+s79yYZKKLWukz62va NiMHEYuH0RmuPEibzcTj2L1+RlidPqoYflpvyx9K/xdr0ssKxwI88alGMcTrO7qeEB19abbbw9S XA9oJjhUpW9FYvlc4EDFaEhC9JxKkKmFDQzqQs5nELCPX X-Gm-Gg: ASbGncv6PTepCvP7M3KKhdiWP2lZxakONQ+vgi9omkbArjySkDky58+s19ESHQCMLOg oI3C1+Q37xQSB1AXvr13Sf2+Ot+6oPA55KJwZDQOXzKFbY/NaOjtBRwD/eCN3T3MJWvw7vOCRo0 QMVCcdTtIliBdzT4dP7LeFXMroshL/mMa7UMFOZ4aGz6XY X-Google-Smtp-Source: AGHT+IEwEBk127DPvRU7G0d7TdkEwvZxHz3ixaLIMVk3yCLs7DEYc6oicjH3BVMmTL7swEo0cj7CodroEGnU0eUctFQ= X-Received: by 2002:a17:907:7244:b0:adb:2bb2:ee2 with SMTP id a640c23a62f3a-ae057f1f567mr299945966b.41.1750430419725; Fri, 20 Jun 2025 07:40:19 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Junwang Zhao Date: Fri, 20 Jun 2025 22:40:07 +0800 X-Gm-Features: Ac12FXyozk83E1XeOx9lbB37tA35C0qn0LLLu9x5iCKkROhgdDPdQdnTai1doWU Message-ID: Subject: Re: Fixes inconsistent behavior in vacuum when it processes multiple relations To: Michael Paquier Cc: Nathan Bossart , shihao zhong , PostgreSQL-development Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Jun 20, 2025 at 9:34=E2=80=AFAM Michael Paquier wrote: > > On Thu, Jun 19, 2025 at 03:30:26PM -0500, Nathan Bossart wrote: > > After thinking about this some more, I'm wondering if it would be bette= r to > > pursue option (2) because it's a little less invasive (which is importa= nt > > because this will need to be back-patched). In any case, we have a sim= ilar > > problem when recursing to the TOAST table, which can be fixed by copyin= g > > the params at the top of vacuum_rel(). > > > > While testing out the attached patch, I noticed a couple of other > > interesting problems in this area [0]. > > > > [0] https://postgr.es/m/aFRxC1W_kZU9OjJ9%40nathan > > Hmm. I like the simplicity of option 2) for the purpose the back > branches and the post-feature-freeze v18. > > However, Option 1) would be my go-to option for HEAD (as of v19 > opening for business), but I think that we should harden the code more > than suggested and treat all VacuumParams as purely input arguments > rather keeping some pointers to it depending on the code path we are > dealing with, so as no callers of these inner routines is surprised by > changes that may happen internally. I'd suggest just marking the VacuumParams *params with const, so that the user can not change its content, or the compiler will error out, it will force the user to make a copy if changes are needed. I see vacuum_get_cutoffs already has the const signature. Passing by const pointer is more efficient than passing by structure value. > Hence, reading the code of v2, > I'd suggest to apply the same rule to vacuum_get_cutoffs(), > do_analyze_rel() and heap_vacuum_rel(). Except if I am missing > something, it looks like all these calls should be OK with this new > policy. This implies also changing relation_vacuum() in tableam.h, > which can be a HEAD-only change anyway. > -- > Michael --=20 Regards Junwang Zhao