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 1ttwR0-0029Ty-6Y for pgsql-hackers@arkaria.postgresql.org; Sun, 16 Mar 2025 22:26:18 +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 1ttwPz-001sGU-Ox for pgsql-hackers@arkaria.postgresql.org; Sun, 16 Mar 2025 22:25:15 +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 1ttwPz-001sGM-9r for pgsql-hackers@lists.postgresql.org; Sun, 16 Mar 2025 22:25:15 +0000 Received: from mail-ua1-x936.google.com ([2607:f8b0:4864:20::936]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ttwPv-003FYY-04 for pgsql-hackers@postgresql.org; Sun, 16 Mar 2025 22:25:14 +0000 Received: by mail-ua1-x936.google.com with SMTP id a1e0cc1a2514c-86d30c329f2so3673473241.0 for ; Sun, 16 Mar 2025 15:25:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xzilla-net.20230601.gappssmtp.com; s=20230601; t=1742163910; x=1742768710; 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=xWbr8rrRaXap3gybDtkZIEgY9XeJraSBWZwAjBPbndA=; b=edAuZThqEE6q04IK79LhW/v1HssO1+riLugTWzeipcxBEfSnCNdEchA3O3113qax5Y 9cp6OWXBaCSG2kzCmJOjOXVYyPXZke45m3leN+zw63unkqbyV1DNN1Evc4EM2lT8Wox6 dnEayi5ejsSfNBqfOZtk+YR5FbYnTNG5S3o9K1VlKJiWdGZpqMuewXp95t9tL25b+h9R QQH2J6Ill0HP8kJ7xhgeswj4ztyZUM1U5Qm/X7aXWr3jyQCqw0+O2MWckTnL0VZjIBdX PP55oNaN6Qfe2jpnjqqO28sVHCZwWUhTCRgTOyGOibZLgOk6DGnI1qTRfdPRuaGrNEIo 7/0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742163910; x=1742768710; 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=xWbr8rrRaXap3gybDtkZIEgY9XeJraSBWZwAjBPbndA=; b=Cz6Q5iEwLDHUkIXw8synbX8lDoy4pK5iO5h2oi6zFBoG9XmBBvCgipwJuOMt5RByoL 5lPZU8eUh3nNEi+8CzsnAqEk5ODhQ6jcC5q9WgcWcLtZkx7ljvO7N1CceTjDuL6e/wzU ZXQx4Jmx2NgU2bZ0TGyz9TiABh20953kgOBWhlTotGyhzR8jgk2aR+i3+5qAaA+x4/qc BsF4QLGDmGgrGTkbjR2SxXqDeLIph0LrO44y//usERzZUUd2utMfSS39pB0CcXE8mlW/ 6GTJAt65YsEU8R83o9LsiY2WkbAI0R8zum4dd6m1NuUKCk+CWMH1HyZ/9v3TCAYcStGM HnIA== X-Forwarded-Encrypted: i=1; AJvYcCV/q0hxvYNLK4uUOdB+tqbKhVe0MEeatXcX7hiUO/WGOglbuOfLhXwJPIk2ND1FLuv3+YnOLoPEvo/FIkyV@postgresql.org X-Gm-Message-State: AOJu0YyyCHDub1HYehYREC/5i0IntJKfW0/Rm22w+Lq8zC9Pdyp3MVAf XVGMPDgukbFmnlfWR87TjPKdZHYcv5gICFpwlhZsapYNuSNAFW1vjxPNmY43Ow+hYS23t2/FjGk NqJfJjXW7QhUqbfSn6kz6NckvHJGbAIIbOP0PYA== X-Gm-Gg: ASbGncvB3JjxkNXNm1BL5whgq7mV1j35MOzivwAaydm5adW9njNg5qtWEGpQ85fs4xT pEq+7qyF+01LvK8KddZ/KAFOYJ13XOiHsK67lcook7oruGNIVlCfpSPzui04Eoun/zvHeOiaHbT JkYEWNDpRNqOKs08khK3P9odeLNJuI9STBdMys X-Google-Smtp-Source: AGHT+IHceT2E8JZolxpg5wKpFsqrYkmJ6RWiRENRsBHH8TQAO7cWy3mGuYwBl3Rc6klziTfgzSmORH3xBU3UTX7HCmU= X-Received: by 2002:a05:6102:3752:b0:4c2:fccb:a647 with SMTP id ada2fe7eead31-4c371bc66a6mr12600437137.5.1742163910384; Sun, 16 Mar 2025 15:25:10 -0700 (PDT) MIME-Version: 1.0 References: <28773a66-fb88-41cf-a7ec-4216e6c91c94@oss.nttdata.com> <6f2f2167f4be09e6ca9251c8f69dfe01809d68be.camel@cybertec.at> In-Reply-To: <6f2f2167f4be09e6ca9251c8f69dfe01809d68be.camel@cybertec.at> From: Robert Treat Date: Sun, 16 Mar 2025 18:24:59 -0400 X-Gm-Features: AQ5f1Jrn7zcbP7Ug0SufG7UMjdnBsLajiIFRV8P8ZofXteOZMBfHvxCg2owuqsM Message-ID: Subject: Re: Disabling vacuum truncate for autovacuum To: Laurenz Albe Cc: Gurjeet Singh , Nathan Bossart , Andres Freund , Will Storey , Fujii Masao , Robert Haas , Postgres Hackers 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 Sun, Mar 16, 2025 at 1:29=E2=80=AFAM Laurenz Albe wrote: > > On Sat, 2025-03-15 at 17:14 -0700, Gurjeet Singh wrote: > > > One other difference in my version of the patch [0] is to call this G= UC > > > vacuum_truncate and have it apply to both autovacuum and VACUUM. I d= id > > > this for the following reasons: > > > > +1 for the GUC name for the reasons you identified. But -1 for the beha= viour > > where the reloption and vacuum command's options overrides GUC. > > > > I'd like to bring our attention back to how this thread started. Will s= tarted > > the discussion by asking for a way to disable autovacuum's truncate beh= aviour. > > Even though the production outage he faced was due to manual vacuum, he= was > > worried about the same behaviour that autovacuum may cause, especially = since the > > parameter old_snapshot_threshold is no longer available; old_snapshot_t= hreshold > > allowed sysadmins like Will to disable the truncation behaviour globall= y. I > > provided an anecdote where autovacuum's truncation behaviour had in fac= t caused > > a replication outage as well as the consequent application outage. > > > > The behaviour that is being proposed here does not prevent that situati= on from > > arising again. A sysadmin who's trying to prevent replication outage an= d > > a consequent application outage won't benefit from tuning vacuum_trunca= te GUC, > > because a reloption or VACUUM (TRUNCATE) command will override its beha= viour, > > and lead to an outage. > > > > We want this new GUC to give the sysadmin the power to override the per= -relation > > and per-command settings. > > > > > > I guess what I'm looking for is a global switch that guarantees no rela= tion > > truncation will take place on the instance, so that the relevant replic= ation > > record is never emitted, and hence will never lead to a blocked replica= tion on > > the replica and never cause a consequent outage of applications connect= ed to the > > replica(s). > > Essentially, you are looking for something that reinstates the unintended= side > effect of "old_snapshot_threshold" that some people relied on. > > I understand your reasoning. > What I am worried about, and why I am against that, is the POLA violation= this > constitutes. I PostgreSQL, there usually are global settings that can be > overridden by per-relation settings. Doing it differently here would sur= prise > and confuse many users. > Agreed... I couldn't help when reading through this thread the same thought that the normal way we do this is by trying to pick the sensible default and then giving options to override it on a more granular level. > This is not the only way a user can do damage to the system by overriding= the > administrator's settings. Users can override all autovacuum settings and= even > disable autovacuum on a table. I don't think these settings are less dan= gerous > than VACUUM truncation. > Agreed. To the degree I am sympathetic to Gurjeet's concern, it sounds more like he is trying to solve a socio-technical issue, which I think is beyond something that we can guarantee help with; ie presuming we provide a convenient way to disable this generally, if people are going to go out of their way to do the thing they have been told not to... So if the general idea is a guc "vacuum_truncate" which sets a global default for whether vacuums and autovacuums should do truncation, and we then have the storage parameter which would override the global setting. And to be clear, there is also the decision on whether the VACUUM commands default should default to truncate=3Don (like the existing behavior) or truncate =3D=3D vacuum_truncate guc, unless explicitly set. I think the latter is probably the right way to go. As an aside, thinking through a bunch of different scenarios, I think I would actually be in favor of changing the default behavior to false (I don't think it buys much for most workloads, and I'd love to see us move towards defaults that minimize risk), but I suspect that may be a bridge too far, at least in this release; but maybe down the line... for now though I'd take an easy way for users to make it the default. Robert Treat https://xzilla.net