Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vWKf1-00H9dg-1y for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Dec 2025 20:31:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vWKf0-004DSX-0o for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Dec 2025 20:31:43 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vWKez-004DSN-39 for pgsql-hackers@lists.postgresql.org; Thu, 18 Dec 2025 20:31:42 +0000 Received: from mail-qt1-x829.google.com ([2607:f8b0:4864:20::829]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vWKez-001O9V-11 for pgsql-hackers@lists.postgresql.org; Thu, 18 Dec 2025 20:31:41 +0000 Received: by mail-qt1-x829.google.com with SMTP id d75a77b69052e-4f34c5f2f98so11495911cf.1 for ; Thu, 18 Dec 2025 12:31:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766089900; x=1766694700; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=NboMMhEUl5Y/1IbyRQ5nTdozJURY9oZRxm5nQnx3awQ=; b=cSe/GM8Vjj06diRmHerIDg2waEjurkNRNN47sv1KSXG/epBfz6M2K6K0GmjNUs4/DB 5nKxMhiETm1JxeMOSHnFoAFIAemyVTYztk3XWk/Jrb/TgN/1I/xb8Fwk8bR4pLHrjd5B F7IsJyujNq2BrbLrpKT/kjWBM8vmsqEbP7d/eL6k8fDXn2FLmoIrwxlFnO/x+fbIwoKO HoDjm62LCoZlSZz2dLWW2G8J968zdWJR2v5xSnJgRmuhKrN3eJJ1YOkkDDGZUZlXs+le cJZAXc8Kvb+i9rO6l6yBPlqLv8ozgFWKC4otfYhkeVc4cdWBOOEtmjEVLOhHPWemvWl4 30qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766089900; x=1766694700; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=NboMMhEUl5Y/1IbyRQ5nTdozJURY9oZRxm5nQnx3awQ=; b=jmlGuqBc/8MIY09jBS0aOTU2TLHc8ZXEUln0PPi+IbolnYkgmyjSQsOr+QSzMl5kBM n63bzs18X0AkrEiXblGn6tNOhWDDBmPtBAvcFytcaYKRbiQRQoL44XnHH5ClHE6xSc0M ZtMdEOO1NeydHsuA3VFqh4I8zhUw3twgA64Tgn3ZTJKtgGTC5c+A54cHGten/6nCrzxC C2bx4l9vTPFSc+pUoXPpl3wuDVie16qTfzc0QJO1uX7orrHQqHEgzjnckV49Tb72bPnG KMYrfirFcsRIIy2O1OP1VkL57JumYH0UXz9MFOYAXQ29otpz044JrqysovZadpEEJSzE NGQw== X-Forwarded-Encrypted: i=1; AJvYcCV16X+V8F0bgBSE0xayVBPI8sT24NYJICQxYs5oiwolgEjl/3tTi5rGGMY6X1sgDH/w3elt7n3+8XtTnc6n@lists.postgresql.org X-Gm-Message-State: AOJu0YwLGyOUEyqwwIAYsKLX+j0/2OFR/2Hz3bhUQ0uPK0b1WolTXvq9 eAqVcVnxmOEyC+8pc+X0u/liHHf6akVx8K/45GhA/aw9er7qVbP/icp7zaOiQ4iGrqDZkVSUIF9 d1auHMBVFliWTwpwudIn33IXpgwUGqho= X-Gm-Gg: AY/fxX4V+8ClLnQZnDD3tcB+UsX92D0NtUZo2S9nQ0VwhLLgNYjc90q6gYnnIOhXpMe QVqM0QNzNE3niNMRD/ROvNIEQ1VHAl8K6L7OWQ18q/M6FlFW5YKjSkrkUYGQniXLfajyVQnczax 3ZgroVbfLKDPi/DHDnn/owmvD/1J/9Dxt1goFhMapoFv4d5LXJET/nej5SJ1fkbrpwGfbN3FoxS ARhIlOwUtiGGFVHrYtsX+qeu46rHOKKRbNholiffaziGbX2HV9h5VObXXNE3OG15IPvygerl7OV /WOAwIOk X-Google-Smtp-Source: AGHT+IH2/T8I435LiKC27eJikr8kBIHcL0WsfZuJoKxEdLpyl67mUgpOr2wzwH3Z3nRAqoRpse0ttBQ6xww1NHfBFyk= X-Received: by 2002:a05:622a:4c15:b0:4f3:59a7:67b3 with SMTP id d75a77b69052e-4f4abcf0be2mr8595651cf.20.1766089900147; Thu, 18 Dec 2025 12:31:40 -0800 (PST) MIME-Version: 1.0 References: <2wk7jo4m4qwh5sn33pfgerdjfujebbccsmmlownybddbh6nawl@mdyyqpqzxjek> In-Reply-To: From: Kirill Reshke Date: Fri, 19 Dec 2025 01:31:27 +0500 X-Gm-Features: AQt7F2q3Q5wBCCvnT4Oo4Zqu5J2xLxLfWXvdc9v8LJ_sMjWzrzD1WbfvepzIU1Q Message-ID: Subject: Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access) To: Melanie Plageman Cc: Andres Freund , Robert Haas , Andrey Borodin , PostgreSQL Hackers , Heikki Linnakangas , Chao Li 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 Fri, 19 Dec 2025 at 00:58, Melanie Plageman wrote: > > On Thu, Dec 18, 2025 at 1:07=E2=80=AFPM Kirill Reshke wrote: > > > > On Thu, 18 Dec 2025 at 20:18, Melanie Plageman > > wrote: > > > > > But you are right, I don't see any non-error code path where a heap > > > page would become empty (all line pointers set unused) and then not b= e > > > set all-visible. Only vacuum sets line pointers unused and if all the > > > line pointers are unused it will always set the page all-visible. > > > > > > I think, though, that if we error out in lazy_scan_prune() after > > > returning from heap_page_prune_and_freeze() such that we don't set th= e > > > empty page all-visible, we can end up with an empty page without > > > PD_ALL_VISIBLE set. You can see how this might work by patching the V= M > > > set code in lazy_scan_prune() to skip empty pages. > > > > Thank you for your explanation! I completely forgot that PD_ALL_VIS > > is a non-persistent change (hint bit). so its update can be trivially > > lost. > > The simplest real-life example is being killed just after returning > > from heap_page_prune_and_freeze, yes. > > PFA tap test covering lazy_scan_new_or_empty code path for > > empty-but-not-all-visible page > > Cool test! I'm going to have to think more about whether or not it is > worth adding a whole new TAP test for this codepath. Is there an > existing TAP test we could add it to so we don't need to make a new > cluster, etc? How long does the test take to run? Obviously it will be > quite short, but every bit we add to the test suite counts. I don't > actually know how much overhead there is with injection points. > Well, on my pc this test runs in ~1.5 sec. I did not find any other TAP test to place this, so created a new. Actually, I only check for specific patterns in the log file of the cluster in this test, so this test can instead be a regression test. ``` reshke=3D# VACUUM (DISABLE_PAGE_SKIPPING) vac_empty_test; NOTICE: notice triggered for injection point vacuum-empty-page-non-all-vis VACUUM reshke=3D# ``` We will just check in the .out file that the code hits 'vacuum-empty-page-non-all-vis' after an error. injection points overhead should not be that awful, just from my experience. Maybe buildfarm members can say something here, I dunno. Also, we already have a bunch of regression+inj point tests for some rare cases, exempli gratia src/test/modules/nbtree/sql/nbtree_half_dead_pages.sql. --=20 Best regards, Kirill Reshke