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 1mzn86-0003OG-7I for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Dec 2021 21:57:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mzn84-0004Ub-Vk for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Dec 2021 21:57:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mzn84-0004US-JQ for pgsql-hackers@lists.postgresql.org; Tue, 21 Dec 2021 21:57:04 +0000 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mzn80-0002HE-Jr for pgsql-hackers@lists.postgresql.org; Tue, 21 Dec 2021 21:57:04 +0000 Received: by mail-ed1-x531.google.com with SMTP id m21so1867494edc.0 for ; Tue, 21 Dec 2021 13:56:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bowt-ie.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lxmR7d5+HrGkEbLy2AJmfKZBrRMrKB7bUX54we5W8Nk=; b=Y3D/dD5DwiquuYMYyod9+qymbe+XiulYIjInd7SQUDk8d3OlNau4itGJb5po5ZKH2k V6b3Y4A2fWKAOrPq/GcTOVsAudrbUwitfO4/UoBCGSVy1QmL9aW02SSh5ab173oSMpQw 4Gv8gcDAfbsHPQVqzSSaHhmJAi9F2CXK7B7/TmZG/2hrOpk/8Rl7EjX6y5Fd9JpwgLCr eXGSBxuWg9Z0p2uMGXMtwhoLkxgTzleQePYd1qjGhAn8NXy9LriGd5wHMEBXjhOdIEgp oKBxnQe8PmVPRzoD0zra1BN0oJAkzJeDUO2gWkWSfoqRsjEIhfLP/8TpZffk2tVtMBLc nnig== 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=lxmR7d5+HrGkEbLy2AJmfKZBrRMrKB7bUX54we5W8Nk=; b=lZKRwjbI6T1qcyPlb9uKw9XzQfD2xWpY7xKeDUsJYLo7/6FXRCYL+wASMGPnbH3aKn jIHIeFzDDcwNGcC4mRocznEIGYktaX3XIMjHoFf0/EpkFcFSb6n9vW0LBDBsmIov0e9k on+zl8iMPodswcMIAng42speLFV8V6PL8oSAZBBajTJUKo187Z7UL76BXj5+11/G/4JI HTPrObWtCg32sUDJl+200AVkp5iMxUAsLlBpIncvQsaqI1fexM+arlKe5hyXBTOv6vbJ oiI4QMwYUHUHI6/V80OhjtN4XTeUtUvyQLmOhfwOU2WYvUK7hwleROe09xZDxXZGgLYP QPGQ== X-Gm-Message-State: AOAM532ws/CAU+jqRym/fAM00jAezxzQDOUGqRk3naYbAdP8R32rEBFv 96CGNg1HygXr7Ky12kfNp/0zg5wmi0o4E55euT4JlQ== X-Google-Smtp-Source: ABdhPJwlz4jm03axlusOoCAGbUvf78womKrViJqjuO+gKQEJi3pHtAjQJw22zwjpyPiw1HcCiealNDwJ6WUwPMq3MOs= X-Received: by 2002:aa7:c744:: with SMTP id c4mr233951eds.85.1640123816904; Tue, 21 Dec 2021 13:56:56 -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: Peter Geoghegan Date: Tue, 21 Dec 2021 13:56:30 -0800 Message-ID: Subject: Re: do only critical work during single-user vacuum? To: John Naylor Cc: Masahiko Sawada , Andres Freund , "Bossart, Nathan" , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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.) 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. -- Peter Geoghegan