Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nJqxP-0004qC-Bu for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Feb 2022 06:04:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nJqxO-0003Mp-8l for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Feb 2022 06:04:58 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nJqxN-0003Ma-KS for pgsql-hackers@lists.postgresql.org; Tue, 15 Feb 2022 06:04:57 +0000 Received: from mail-oi1-x231.google.com ([2607:f8b0:4864:20::231]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nJqxK-0004cN-GV for pgsql-hackers@lists.postgresql.org; Tue, 15 Feb 2022 06:04:56 +0000 Received: by mail-oi1-x231.google.com with SMTP id s24so19805073oic.6 for ; Mon, 14 Feb 2022 22:04:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0QM+fTjwS9XyjYwNEBu7cpduZ/+7McmN1EYK9o/Yr7U=; b=aSTwGSXHxIRkcm0yPwN1D4dRxyzXpOkqYM5OXn/bS0B1yry/jv1zO4YYrV9g02z6cd WPtzeFfyNCYi+uGct4Ej+283fBrCBLkH9h+cVo4uWq05RrJRLHfnDrGPDE6J8vxOPL96 aoA4obAr6GgkuC2w6sdXcL69RcKXZ8dA3LcuANAb+4AxPwjDWqo6dHcBIePLC1SyBwiP /A6lZ3xstY+qa8JzuXaklrUcKC1KnEufI0pWTkXeNCGjItwYHZ8VKdHI47dFQtsoV5c+ HgTFp1nINS9tEIcbQMmRFv6OZlc3obW/6dFq6HQZrEnIHWHf87CowwoQBYvP5qkaOI/2 LExQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0QM+fTjwS9XyjYwNEBu7cpduZ/+7McmN1EYK9o/Yr7U=; b=PLhpw8jA/jnSeoUpppUY6xJIs22vmOMInVB3dXgb9iKed7mzFgALkjswBWvmmUlpWX 8I6M3E29QpiM4+cOv5UXt367gTlxHnZqnVJQEenRR5k1geoibyQiN7tH2SzfIjuM8wyB j5+ybnKA+ZEvunxjUUX5wa4uYjrTaBuTZOKlmDH0KgUFowpPgEXyu9RhxCahzuSrHXhI QRdoxWg5cKbYTH9xEeTnPN+FPsTKpCxTvSLD4skHL41+0cIXTPRTabMt0yP/ZeQUcAQK SvFZuJ2HEquoJgL9nYi8RTx3I6/AYPnzCRZhDL5hNyu5zb1LRlKmZ+qXdUJ/1DXzjeNC znuA== X-Gm-Message-State: AOAM533DkixnZOOHIcwwGDYbiAKRcclk1o8ooYtbQdUZ0gFp8HZ56m08 O7ALvCGQ/eMHnLpg6uwzo3c04jjbw65tm1JFYfuBPfBzdjFoUkr40LOfTnhcgvheXwHKJDq1vo+ CYRmicVDnhwkRBvxrhTfJV0HKII7ID4YVvKm7ARdZpIu0YXYYYDayWN3wdlqRAUrN4clD6oQI3N BTku5Qq9yIqDFWrjTTtQWg+X8Erwmyg1F95RSACVmJFLggYRMRHH9dS8zSksamqVT9w6jK0B0iA rOd X-Google-Smtp-Source: ABdhPJyfaKCOGbNIuoPR8QGHe7WjcUj253UXbLXl0W17lST/2VfRJNoszxsBbKXPY2SA9sHHACxCj/AXQqXQVZosdHE= X-Received: by 2002:a05:6808:1886:b0:2ce:6ee7:2ce5 with SMTP id bi6-20020a056808188600b002ce6ee72ce5mr962480oib.275.1644905093356; Mon, 14 Feb 2022 22:04:53 -0800 (PST) MIME-Version: 1.0 References: <20211210015616.o242b4xchhpglfcy@alap3.anarazel.de> <20220203215048.rmwjzixdzaetedxq@alap3.anarazel.de> In-Reply-To: From: John Naylor Date: Tue, 15 Feb 2022 13:04:42 +0700 Message-ID: Subject: Re: do only critical work during single-user vacuum? To: Peter Geoghegan Cc: Andres Freund , Robert Haas , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Feb 15, 2022 at 11:22 AM Peter Geoghegan wrote: > > On Mon, Feb 14, 2022 at 8:04 PM John Naylor > wrote: > > The failsafe mode does disable truncation as of v14: > > > > commit 60f1f09ff44308667ef6c72fbafd68235e55ae27 > > Author: Peter Geoghegan > > Date: Tue Apr 13 12:58:31 2021 -0700 > > > > Don't truncate heap when VACUUM's failsafe is in effect. > > That's true, but bear in mind that it only does so when the specific > table being vacuumed actually triggers the failsafe. I believe that > VACUUM(EMERGENCY) doesn't just limit itself to vacuuming tables where > this is guaranteed (or even likely). If I'm not mistaken, it's > possible (even likely) that there will be a table whose > age(relfrozenxid) is high enough for VACUUM(EMERGENCY) to target the > table, and yet not so high that the failsafe will kick in at the > earliest opportunity. Well, the point of inventing this new vacuum mode was because I thought that upon reaching xidStopLimit, we couldn't issue commands, period, under the postmaster. If it was easier to get a test instance to xidStopLimit, I certainly would have discovered this sooner. When Andres wondered about getting away from single user mode, I assumed that would involve getting into areas too deep to tackle for v15. As Robert pointed out, lazy_truncate_heap is the only thing that can't happen for vacuum at this point, and fully explains why in versions < 14 our client's attempts to vacuum resulted in error. Since the failsafe mode turns off truncation, vacuum should now *just work* near wraparound. If there is any doubt, we can tighten the check for entering failsafe. Now, it's certainly possible that autovacuum is either not working at all because of something broken, or is not working on the oldest tables at the moment, so one thing we could do is to make VACUUM [with no tables listed] get the tables from pg_class in reverse order of max(xid age, mxid age). That way, the horizon will eventually pull back over time and the admin can optionally cancel the vacuum at some point. Since the order is harmless when it's not needed, we can do that unconditionally. -- John Naylor EDB: http://www.enterprisedb.com