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 1nJpM3-00055s-6h for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Feb 2022 04:22:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nJpM1-0002mU-RX for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Feb 2022 04:22:17 +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 1nJpM1-0002mK-Eq for pgsql-hackers@lists.postgresql.org; Tue, 15 Feb 2022 04:22:17 +0000 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nJpLu-0003tm-62 for pgsql-hackers@lists.postgresql.org; Tue, 15 Feb 2022 04:22:16 +0000 Received: by mail-ed1-x533.google.com with SMTP id w2so11448931edc.8 for ; Mon, 14 Feb 2022 20:22:09 -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=wsfjDkT+5UrJjvzKvla9UlMQRUaiZHsLC1GhrfdjBO4=; b=CA+cKnLOiiDFT+02fjskDOFCZPIIjoGFWcjTptp/h4VZWm2iKgCEadDWdqM23TLQZ0 qOmq6zI7aYF8edjNleAGBH/POk6IOTt7bABj4qUq1AKDBH1ZwHElDN0X972NhH8bn89m eFJ+5qsJGEIECRHlXly9BSMOKtsjoKYcvSm4H+7WGOIhj7ldTNnRg2ySMV3yxThr6ooe 5ed8PCHqionmWj00YQ/lg+qVpfQI3IdEAnqBPOjSzbBkGkR7QHVQQZBgYpvfKLnboB1S A1TD0Dnl1X5Ddvx9NTr4W4E1otuvVwOwrywkRJRd9ukxn/nyhDx5aRF+d6mG/Y/ZIfK4 FvYA== 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=wsfjDkT+5UrJjvzKvla9UlMQRUaiZHsLC1GhrfdjBO4=; b=T4wu38tF3W5QSSzlDcZ9tpeSR6mw6+n2nBIxhQqsswVPYuy2y/NPZQ4NtIuYFN/bfF Bl4uzE4EV3ZF1tG6LmwrPEUpeKZDZ0gS+V26NqBAtZ07r/caZjdmsWbqdd0gQ7XrgRHC nR4a5fjnWUcM5GqGUHeoOSFwXLwzKlho3U1wj7nDKt8APhDL0FUf3MEPpguchSY+hvt9 XGDGKWvOEduS0m0LrKT9A5HNqcB8DW4n1YSRqQcxipFv08/37RjLXd0t0jucQTwIg3QG UNvzJSsVQ5JNojBvqtjK46h56MIWC/VSIKOzamjlfARjS17wlrB3WTuoBzGyebswd2HF 7fpQ== X-Gm-Message-State: AOAM5317OS4nZNUEych6FWo5rrLMqzq9KOrt4asX8k2YXmPBeHxoGAQA zpGApTx5Q6UAD52TL+kd5/aYXjRnqX+WOsPHIbsfjw== X-Google-Smtp-Source: ABdhPJw9eZmRaULEL3LBVwQ3eD3R5eB812X0VfMJaMLhP9f72/mwKLC0bXXw83w2mWXBXVEba8C0unS8fl7D4Zif62c= X-Received: by 2002:a05:6402:3509:: with SMTP id b9mr2037761edd.192.1644898927457; Mon, 14 Feb 2022 20:22:07 -0800 (PST) MIME-Version: 1.0 References: <20211210015616.o242b4xchhpglfcy@alap3.anarazel.de> <20220203215048.rmwjzixdzaetedxq@alap3.anarazel.de> In-Reply-To: From: Peter Geoghegan Date: Mon, 14 Feb 2022 20:21:41 -0800 Message-ID: Subject: Re: do only critical work during single-user vacuum? To: John Naylor Cc: Andres Freund , Robert Haas , 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 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. > To demonstrate to myself, I tried a few vacuums in a debugger session > with a breakpoint at GetNewTransactionId(). I've only seen it reach > here when heap truncation happens (or the not relevant for wraparound > situations FULL and ANALYZE). It's possible for a manually issued VACUUM to directly disable truncation (same with index_cleanup). Without getting into the question of what the ideal behavior might be right now, I can say for sure that it wouldn't be difficult to teach VACUUM(EMERGENCY) to pass down the same options. The failsafe is essentially a mechanism that dynamically changes these options for an ongoing vacuum, once age(relfrozenxid) crosses a certain threshold. There is nothing fundamentally special about that. -- Peter Geoghegan