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 1mzrXa-0005UE-EI for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Dec 2021 02:39:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mzrXZ-00028Y-Bg for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Dec 2021 02:39:41 +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 1mzrXZ-00026E-0y for pgsql-hackers@lists.postgresql.org; Wed, 22 Dec 2021 02:39:41 +0000 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mzrXW-0002z0-Gx for pgsql-hackers@lists.postgresql.org; Wed, 22 Dec 2021 02:39:40 +0000 Received: by mail-pj1-x1030.google.com with SMTP id v16so952494pjn.1 for ; Tue, 21 Dec 2021 18:39:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=GgCOb2aKZKzRd5JB+uRhD0LTMcbGpG1T914NK4jkAfw=; b=dILOo1OdqCfBIatsJyCngg5N1nAEdYZR0IYVOcaggqtNGRxZjYm/eV3M++LJ5lUvBI tKZI6NnsFVVNme92B5zEd2Cw2rliTLx3zzJJp9zy9DQj0q3YNC+1E05K1DO3GyiGt+/+ xYB6q6DrrAZyx253nVEmoXNK6EDWqbq+g72KHwISlwiSSFrkx90etpkTxd/K8jPAL99b 8aU9B/2iUeWclKyJqL6jHcnH3M4zkxUFF5e0xAeqUmN2I7fpGDc1fXfF9+kINvaxQ4qQ OSJoy92Q7+eHkClhcd2duYw4HqOFx/M8sz3VSrm/ymWgO+33TJfReWd2oE9jgUQK29dl z8oA== 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:content-transfer-encoding; bh=GgCOb2aKZKzRd5JB+uRhD0LTMcbGpG1T914NK4jkAfw=; b=en4Qo1NJC0F6jrSHLQthv/g/9k4j98lgQuKZ+uDQyCJE9ZKFOFWDtLk+qhe0DDT/L+ HpHOwehJV2W/4pq/xYC7vg6IeolShWWtLAW/x/SdaOfTrr8hnRy39ipxwpbpSlX/zcfM FfJ0YKji3zDeXONewx1tRA0+gMkg+ufMWfK9bAAN/HUX2km/UdboMFKxiBM+hPVa2X75 ykZ2gS3znuvl4CguK/XQ8QKU/8Tl6Y6c29lfSIWKbaYbm89ySQApqgwfD7ClPGxgbc8b /6T0jT/VuhYH+kdCNLH8iEN9Gq/A3IedQlOtLt8a1blNQq8n2D8spVeJXhiyl5+tLVz2 N+hQ== X-Gm-Message-State: AOAM532GLY8ZUXhkftGMI4vx7A0U7TUoHFJQPXw54iaggvv2qmJLTQoF xfP3eR9lJZzN46uffS7BjlheH/F4klgiT4GtVxk= X-Google-Smtp-Source: ABdhPJyXBb4kUajr5/ito+RpdLCLMd71/4j2ZZyUs8ueaT8jNgSJGNgBMLh1xnc+Y6xM2mV8H1jBl3OsCWCmWIqf38c= X-Received: by 2002:a17:902:d484:b0:148:e505:7de9 with SMTP id c4-20020a170902d48400b00148e5057de9mr889580plg.14.1640140777206; Tue, 21 Dec 2021 18:39:37 -0800 (PST) MIME-Version: 1.0 References: <3F7FD826-36EF-4991-AB37-81675AFEBF54@amazon.com> <0544901A-0FC5-46B5-801B-F30AC0B81A19@amazon.com> <20211221034630.maoteglpjqpgh62g@alap3.anarazel.de> In-Reply-To: From: Masahiko Sawada Date: Wed, 22 Dec 2021 11:39:00 +0900 Message-ID: Subject: Re: do only critical work during single-user vacuum? To: Peter Geoghegan Cc: John Naylor , Andres Freund , "Bossart, Nathan" , PostgreSQL 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 Wed, Dec 22, 2021 at 6:56 AM Peter Geoghegan wrote: > > On Tue, Dec 21, 2021 at 1:31 PM John Naylor > wrote: > > On second thought, we don't really need another number here. We could > > simply go by the existing failsafe parameter, and if the admin wants a > > different value, it's already possible to specify > > vacuum_failsafe_age/vacuum_multixact_failsafe_age in a session, > > including in single-user mode. Perhaps a new boolean called > > FAILSAFE_ONLY. If no table is specified, then when generating the list > > of tables, include only those with relfrozenxid/relminmxid greater > > than their failsafe thresholds. > > That's equivalent to the quick and dirty patch I wrote (assuming that > the user actually uses this new FAILSAFE_ONLY thing). > > But if we're going to add a new option to the VACUUM command (or > something of similar scope), then we might as well add a new behavior > that is reasonably exact -- something that (say) only *starts* a > VACUUM for those tables whose relfrozenxid age currently exceeds half > the autovacuum_freeze_max_age for the table (usually taken from the > GUC, sometimes taken from the reloption), which also forces the > failsafe. And with similar handling for > relminmxid/autovacuum_multixact_freeze_max_age. > > In other words, while triggering the failsafe is important, simply *not > starting* VACUUM for relations where there is really no need for it is > at least as important. We shouldn't even think about pruning or > freezing with these tables. (ISTM that the only thing that might be a > bit controversial about any of this is my definition of "safe", which > seems like about the right trade-off to me.) +1 > > This new command/facility should probably not be a new flag to the > VACUUM command, as such. Rather, I think that it should either be an > SQL-callable function, or a dedicated top-level command (that doesn't > accept any tables). The only reason to have this is for scenarios > where the user is already in a tough spot with wraparound failure, > like that client of yours. Nobody wants to force the failsafe for one > specific table. It's not general purpose, at all, and shouldn't claim > to be. Even not in the situation where the database has to run as the single-user mode to freeze tuples, I think there would be some use cases where users want to run vacuum (in failsafe mode) on tables with relfrozenxid/relminmxid greater than their failsafe thresholds before falling into that situation. I think it=E2=80=99s common that users are somehow monitoring relfrozenxid/relminmxid and want to manually run vacuum on them rather than relying on autovacuums. --min-xid-age option and --min-mxid-age option of vacuumdb command would be good examples. So I think this new command/facility might not necessarily need to be specific to single-user mode. Regards, --=20 Masahiko Sawada EDB: https://www.enterprisedb.com/