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 1oSjnA-0006hy-Tk for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Aug 2022 18:47:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oSjn9-00006R-3g for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Aug 2022 18:47:23 +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 1oSjn8-00006E-OI for pgsql-hackers@lists.postgresql.org; Mon, 29 Aug 2022 18:47:22 +0000 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oSjn6-0001XD-9L for pgsql-hackers@lists.postgresql.org; Mon, 29 Aug 2022 18:47:21 +0000 Received: by mail-pj1-x1034.google.com with SMTP id p8-20020a17090ad30800b001fdfc8c7567so509239pju.1 for ; Mon, 29 Aug 2022 11:47:20 -0700 (PDT) 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:to:from:subject:message-id:from:to:cc; bh=DCiVvhLSKrYZO5/TAY5+pEeFKIrbjretdYqD+lsMcOk=; b=fru0XPz7SFGJr6CUr/mVdWfM9yPzwVv5gMmugmsTVJ0XPcLkoh4Ro8WAyQyrPFDpOb mAyIvs83pFJjhOGft6vZzXmTugm7034AKOn8LIaJ16rt8UC1+OLR1OZw69+J0vs9b4WK zkXudIrb5Ip8eKuwCDimsWF64ef+VBtcyWRoH8S+aKd3NRZh0ve2tl9Ppe+zX0DwaGL/ oi/+sBa6jIjSiJ04bwgBhUOkXr6Xbt5gC+lYkymqxtqIAo+azP8u47GlP9zBk3/R8spq v+HkAmVjeNmln7Y9yxTq2Oo3Sgc4ExmuM+1CXRevJ7k1TXrlRLKVz4qTUwCCIBT7Xsel H2rg== 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:to:from:subject:message-id:x-gm-message-state:from :to:cc; bh=DCiVvhLSKrYZO5/TAY5+pEeFKIrbjretdYqD+lsMcOk=; b=eTzj7zxjzXl9IebAKGaZHBPVb10O1+h3570YOfxzhBMvnmqYuphz8U+zfjUUK/zGAu ezHm6PN6tgOyYi5gQoVZXEurenZytYe//CI6u5iprvplR5dRsTpwkfqd3bUjQnnzuXTe 0bLu0tJAxxCrMhEwC5eql7WZ3j73cbculFvRtI6A12Ft+lTdn8FTtNhtzb+ujk0WSyYH W9TGISW1bML80wC3jaSO87fvjXQiu3eQza1Z3WNZ8hger7GI2kd/bbMpDoznFhW/gHu6 XU6FPRgrnj4tE/jXJ34GgkSicbnYgA2bMAQRD5r2B0ZZ/bBGMaaU8gY1nOZ7xCSh7zoV zxjA== X-Gm-Message-State: ACgBeo3BAzuY33Jt6/f9EQORRYw0MxxOu8i6PQfLiQ0ZWtgGCakX/08l T2tAIbIu0yyt4FqHoPdWqNRjxK4OL2jCZxM6 X-Google-Smtp-Source: AA6agR5yVCMdOycN16IDTtZNn7REhciOPR0hMHBdISlL5B/6jzGPrJb2x12TQaKcHSOzxEefiljg0g== X-Received: by 2002:a17:90b:4c52:b0:1f5:5129:af1a with SMTP id np18-20020a17090b4c5200b001f55129af1amr19478100pjb.202.1661798838913; Mon, 29 Aug 2022 11:47:18 -0700 (PDT) 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 p7-20020a170902e74700b00172bf229dfdsm7941861plf.97.2022.08.29.11.47.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Aug 2022 11:47:18 -0700 (PDT) Message-ID: Subject: Re: New strategies for freezing, advancing relfrozenxid early From: Jeff Davis To: Peter Geoghegan , PostgreSQL Hackers Date: Mon, 29 Aug 2022 11:47:16 -0700 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.1-0ubuntu1 MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 2022-08-25 at 14:21 -0700, Peter Geoghegan wrote: > The main high level goal of this work is to avoid painful, disruptive > antiwraparound autovacuums (and other aggressive VACUUMs) that do way > too much "catch up" freezing, all at once, causing significant > disruption to production workloads. Sounds like a good goal, and loosely follows the precedent of checkpoint targets and vacuum cost delays. > A new GUC/reloption called vacuum_freeze_strategy_threshold is added > to control freezing strategy (also influences our choice of skipping > strategy). It defaults to 4GB, so tables smaller than that cutoff > (which are usually the majority of all tables) will continue to > freeze > in much the same way as today by default. Our current lazy approach > to > freezing makes sense there, and should be preserved for its own sake. Why is the threshold per-table? Imagine someone who has a bunch of 4GB partitions that add up to a huge amount of deferred freezing work. The initial problem you described is a system-level problem, so it seems we should track the overall debt in the system in order to keep up. > for this table, at this time: Is it more important to advance > relfrozenxid early (be eager), or to skip all-visible pages instead > (be lazy)? If it's the former, then we must scan every single page > that isn't all-frozen according to the VM snapshot (including every > all-visible page). This feels too absolute, to me. If the goal is to freeze more incrementally, well in advance of wraparound limits, then why can't we just freeze 1000 out of 10000 freezable pages on this run, and then leave the rest for a later run? > Thoughts? What if we thought about this more like a "background freezer". It would keep track of the total number of unfrozen pages in the system, and freeze them at some kind of controlled/adaptive rate. Regular autovacuum's job would be to keep advancing relfrozenxid for all tables and to do other cleanup, and the background freezer's job would be to keep the absolute number of unfrozen pages under some limit. Conceptually those two jobs seem different to me. Also, regarding patch v1-0001-Add-page-level-freezing, do you think that narrows the conceptual gap between an all-visible page and an all- frozen page? Regards, Jeff Davis