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 1pBMDi-00030d-5z for pgsql-hackers@arkaria.postgresql.org; Fri, 30 Dec 2022 20:43:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pBMDg-0002VM-Lx for pgsql-hackers@arkaria.postgresql.org; Fri, 30 Dec 2022 20:43:12 +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 1pBMDg-0002U0-7F for pgsql-hackers@lists.postgresql.org; Fri, 30 Dec 2022 20:43:12 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pBMDd-0002GK-Bc for pgsql-hackers@lists.postgresql.org; Fri, 30 Dec 2022 20:43:11 +0000 Received: by mail-pl1-x632.google.com with SMTP id y19so3903887plb.2 for ; Fri, 30 Dec 2022 12:43:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20210112.gappssmtp.com; s=20210112; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=BIuIGMbSNYtPOQrIlSOKPJWG9QL+cQM7qmSZYxw3k7g=; b=Wh3ESUzQrOMEiQZ1Fw6d5us+/teMR40h0c4HwBvIU6+xX87UT4CIyqmoxsJWvua84F 6Zfpob4pIDJGVEE8iLBMJqivFkJVdU57uBtTNIdHLVxybwL2vljIECFRk335YY70U7BX 2Rla80n3ZcZV/PpgyHgyIe7ok5XSHrfxxthM0KL7z6GBjwHjnqMJMjQ0Ih6Zc/ZVuJC+ 5FhoL0K1LWqpYl3IA4cJ+UpbAfPzdlnEXMY8xg7gC/iJsuMin9Z1YWYhrFtxYno2Ujj8 N7wcDYnYiRgmoxKjHmu+7IqT+BySJ2JMET4TtKQQ9Tji5lb5xt/Mx6C6ufmBPE8vC7zd wfVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=BIuIGMbSNYtPOQrIlSOKPJWG9QL+cQM7qmSZYxw3k7g=; b=HaMnhT9tckbdlQtM9hJviv+lR/u4kr2RBeRbsqrrHftSjjspGV3OLMfTlpOc5B+cZe u0vcWWWBToQ2fQSC6CzMtp07HH4b0C93QYkL319y+KE2CRnSMDmHk5Ze3tZ5Iv9g3LFD 2COg962YkQ7NRSSAgAbzvSHEqUlwrmGsYLAOS6brClUjIAnT65QWDbKqygawnk3vYCFJ V8VmA2CrhBk9mwCaZ9Bi1GGlAlehtIGaIGW32j1Mzuc73Q3FtojmsnpSgURX9EdU2BQ2 W/+0n92xaUwRobTJAXoN7+700qqVgEVBPRrt3FSfoGzJfNyhi5E/1389bGksLa0zyVuZ 5+IA== X-Gm-Message-State: AFqh2kqKE+93Rnb4IP5BfL3beu1UhXyU/shSui0bl34RCklz+zYqCrwh GEXAU/gTZcwp9nmm7qcFrdErQA== X-Google-Smtp-Source: AMrXdXvm1wSKZ+J3APRgZeZIr4ESarwK7qiYWrivBl6vFsZgA9EWnnQ9/Br6MCwlG/GcGVE7eg6pMA== X-Received: by 2002:a17:902:ec89:b0:185:441f:7087 with SMTP id x9-20020a170902ec8900b00185441f7087mr48450969plg.12.1672432986914; Fri, 30 Dec 2022 12:43:06 -0800 (PST) Received: from jeff-laptop.lan (c-73-231-146-4.hsd1.ca.comcast.net. [73.231.146.4]) by smtp.gmail.com with ESMTPSA id ja17-20020a170902efd100b001929dff50a9sm4228240plb.87.2022.12.30.12.43.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Dec 2022 12:43:06 -0800 (PST) Message-ID: Subject: Re: New strategies for freezing, advancing relfrozenxid early From: Jeff Davis To: Peter Geoghegan Cc: Matthias van de Meent , John Naylor , Andres Freund , Justin Pryzby , PostgreSQL Hackers Date: Fri, 30 Dec 2022 12:43:04 -0800 In-Reply-To: References: <20221111034455.GE16809@telsasoft.com> <20221116052023.xg7pwgvx2t3hrgaj@awork3.anarazel.de> <20221206184255.dphhpvsyovqqwfdd@awork3.anarazel.de> <9fd17e87889845d74b8e3fdac7d2748a07950a92.camel@j-davis.com> <68df596638f60989cc72680d7029f0d51ca8cc19.camel@j-davis.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4-0ubuntu1 MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2022-12-26 at 12:53 -0800, Peter Geoghegan wrote: > * v12 merges together the code for the "freeze the page" > lazy_scan_prune path with the block that actually calls > heap_freeze_execute_prepared(). >=20 > This should make it clear that pagefrz.freeze_required really does > mean that freezing is required. Hopefully that addresses Jeff's > recent > concern. It's certainly an improvement, in any case. Better, thank you. > * On a related note, comments around the same point in > lazy_scan_prune > as well as comments above the HeapPageFreeze struct now explain a > concept I decided to call "nominal freezing". This is the case where > we "freeze a page" without having any freeze plans to execute. >=20 > "nominal freezing" is the new name for a concept I invented many > months ago, which helps to resolve subtle problems with the way that > heap_prepare_freeze_tuple is tasked with doing two different things > for its lazy_scan_prune caller: 1. telling lazy_scan_prune how it > would freeze each tuple (were it to freeze the page), and 2. helping > lazy_scan_prune to determine if the page should become all-frozen in > the VM. The latter is always conditioned on page-level freezing > actually going ahead, since everything else in > heap_prepare_freeze_tuple has to work that way. >=20 > We always freeze a page with zero freeze plans (or "nominally freeze" > the page) in lazy_scan_prune (which is nothing new in itself). We > thereby avoid breaking heap_prepare_freeze_tuple's working assumption > that all it needs to focus on what the page will look like after > freezing executes, while also avoiding senselessly throwing away the > ability to set a page all-frozen in the VM in lazy_scan_prune when > it'll cost us nothing extra. That is, by always freezing in the event > of zero freeze plans, we won't senselessly miss out on setting a page > all-frozen in cases where we don't actually have to execute any > freeze > plans to make that safe, while the "freeze the page path versus don't > freeze the page path" dichotomy still works as a high level > conceptual > abstraction. I always understood "freezing" to mean that a concrete action was taken, and associated WAL generated. "Nominal freezing" is happening when there are no freeze plans at all. I get that it's to manage control flow so that the right thing happens later. But I think it should be defined in terms of what state the page is in so that we know that following a given path is valid. Defining "nominal freezing" as a case where there are no freeze plans is just confusing to me. --=20 Jeff Davis PostgreSQL Contributor Team - AWS