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.94.2) (envelope-from ) id 1urLVx-004cGP-9C for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Aug 2025 19:08:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1urLVw-00H2x9-8E for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Aug 2025 19:08:56 +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.94.2) (envelope-from ) id 1urLVv-00H2x1-Uy for pgsql-hackers@lists.postgresql.org; Wed, 27 Aug 2025 19:08:56 +0000 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1urLVu-00241K-0V for pgsql-hackers@lists.postgresql.org; Wed, 27 Aug 2025 19:08:55 +0000 Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-61c30ceacdcso305243a12.1 for ; Wed, 27 Aug 2025 12:08:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756321733; x=1756926533; 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=Hyw/k3Wr9VNRnza81iDes1AoNlPjDnJdYjDTkclCxDQ=; b=XeCSJSZ9fHXS+mDWh0jzXXFZKk6WaEK2cySYioxApaTmxPzoouVY99li4GQvyn1Uj+ 44LFDK43pu6dNRsSiRz/ECa7+73jXkBlIW/AbwRhzDnM1qMb3UNnHV7rCsqB6I5yTeHs enJb+NkRqwbISDYVThhxPn6ydFu7sAT5l/zcfoLHdDVv80BKZGtvKjqkv94gZ0Kr2aOm ZDLwM+YX+ZIfO754TQ0tCK5Aa11g/po1j+UDssb4GpImmVNlOElyXr0oaxKWyQ7A6kDM lprpgbI9sjVIlxfmzH0z4UmgbH6ku4fWI6mkYVPir9FAnUABJoloPN/JGmgWLWwS+ISu yb6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756321733; x=1756926533; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Hyw/k3Wr9VNRnza81iDes1AoNlPjDnJdYjDTkclCxDQ=; b=UA0tyG6yNE2R9vLtI/IJmS/PbdJj+JEADF/0Jrad1YLcx269z4Trbv8RKmW8SrNCGb QJLL3/EpxUap5HNxZTqpCIOyT1E14csHoUq74pnEhWKtwIzZc8bCOVuHIXc5nI2fmIo8 DB9SuqOCVDd/RYtvf57cDsY23c6DHQdhJSuajqWWuYj30qzrTd/jAo4OhJD+LAe04Ean TikCv6Hdhate0XDqGXs4s1TU1gXjm24xSC3zmWw4xZYQvTt6ufIgWZOszogzCGIXDRzQ s0fciQigwqXtQ4aD1ANAX9b92Guh6L7QlaUB7KREJFEmrZ/5VovzBkJz/pg0bKHqqKuV yqBA== X-Forwarded-Encrypted: i=1; AJvYcCX/gthcjTX9DTvWs/hFoD5JqYxGUv4dylKs4FcGCRhGdpavK18gJp4z1AOpdUnkIFQtSy0m4QhM3dDyS2bp@lists.postgresql.org X-Gm-Message-State: AOJu0YwjDNIamGgAUEi7/RiaDOFN7XKQoy2Hk4tIOrN5BHADjb5Zl1Cy LyM7F3mImN3n0kXLzDo8+ib9ttSzIl08O1BTdOGPPNE67XizCQO0G5c6IvbDmTg8LW/0gbcLBFP eIptpTDkLzIeO+eRlSEpc4POQ/A149W8= X-Gm-Gg: ASbGnctZUhh8mDKCeyVYMIjA5dOPsyNPlCBwoa4kCmh1EZ3d2dXMXYFFPze67oLeR/j 3mobbsCLOHUK1nbMWHj4UcXA2zsVSDQma79DQOzL7lsV3s4Qg4p/IhIDrVwOPVPJHjlevvPSEdM N9l+5PRNJ5c0tX+3QIlKStPBiNTacM4IEbKnonU5ajvUVLfpY9i0XWskFuw4kslnecLZ5kZYfWf UOnPEg= X-Google-Smtp-Source: AGHT+IGkFrPXqQyAWiNq2zGjLQ2wwcon6zrv46/RYld6bkwjAfO+3pvkksGPBs5vn+veCOqZOW5l1cES8OqpWs0Ka/E= X-Received: by 2002:a05:6402:274e:b0:615:5f47:8873 with SMTP id 4fb4d7f45d1cf-61c983b7f74mr6080567a12.14.1756321733175; Wed, 27 Aug 2025 12:08:53 -0700 (PDT) MIME-Version: 1.0 References: <87DD95AA-274F-4F4F-BAD9-7738E5B1F905@yandex-team.ru> In-Reply-To: From: Melanie Plageman Date: Wed, 27 Aug 2025 15:08:41 -0400 X-Gm-Features: Ac12FXwdeiByeRKYyzGP5Onu2_HcLTtM2i-D5Y-kBSyHeXXI7AntNEUeNixApVw Message-ID: Subject: Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access) To: Kirill Reshke Cc: Andrey Borodin , PostgreSQL Hackers , Andres Freund , Robert Haas 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 Tue, Aug 26, 2025 at 4:01=E2=80=AFPM Kirill Reshke wrote: > > Few comments on 0003. > > 1) This patch introduces XLHP_HAS_VMFLAGS. However it lacks some > helpful comments about this new status bit. I added the ones you suggested in my v7 posted here [1]. > 2) Should we move conflict_xid =3D visibility_cutoff_xid; assignment > just after heap_page_is_all_visible_except_lpdead call in > lazy_vacuum_heap_page? Why would we want to do that? We only want to set it if the page is all visible, so we would have to guard it similarly. > 3) Looking at this diff, do not comprehend one bit: how are we > protected from passing an all-visible page to lazy_vacuum_heap_page. I > did not manage to reproduce such behaviour though. > > + if ((vmflags & VISIBILITYMAP_VALID_BITS) !=3D 0) > + { > + Assert(!PageIsAllVisible(page)); > + set_pd_all_vis =3D true; > + LockBuffer(vmbuffer, BUFFER_LOCK_EXCLUSIVE); > + PageSetAllVisible(page); > + visibilitymap_set_vmbyte(vacrel->rel, > + blkno, So, for one, there is an assert just above this code in lazy_vacuum_heap_page() that nunused > 0 -- so we know that the page couldn't have been all-visible already because it had unused line pointers. Otherwise, if it was possible for an already all-visible page to get here, the same thing would happen that happens on master -- heap_page_is_all_visible[_except_lpdead()] would return true and we would try to set the VM which would end up being a no-op. - Melanie [1] https://www.postgresql.org/message-id/CAAKRu_YD0ecXeAh%2BDmJpzQOJwcRzmM= yGdcc5W_0pEF78rYSJkQ%40mail.gmail.com