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 1uqzrR-00GWwt-0I for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Aug 2025 20:01:42 +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 1uqzrQ-009co7-72 for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Aug 2025 20:01:40 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uqzrP-009cnz-Td for pgsql-hackers@lists.postgresql.org; Tue, 26 Aug 2025 20:01:40 +0000 Received: from mail-qt1-x836.google.com ([2607:f8b0:4864:20::836]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uqzrO-002101-0G for pgsql-hackers@lists.postgresql.org; Tue, 26 Aug 2025 20:01:40 +0000 Received: by mail-qt1-x836.google.com with SMTP id d75a77b69052e-4b297962525so2077591cf.1 for ; Tue, 26 Aug 2025 13:01:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756238496; x=1756843296; 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=e0HjihKBKYS7LMayU8nqqILOVyz/HmjlESnRzdUsLDw=; b=eaP5zxdF1d2p8Gq6H6b+bnQlvo7r8ZScw0qkcHlaBzY5O8LyCTU06o0tLH3zlYuU8S pmoml/AXvtfRBYegcpaoAwQHVuJFxt6ybr0AbhPTcbLQMRy2AmST3ShQ27LiB6ULK4r4 olhgnO0iGTLIPtv4Aj7AXLfD9Iu5Zv5mLmh6DeQ5ct8k8Kp+TVEh+lCC1XIrVQ0ELjcx qptNIK9K3hy8K5buQYNGKgz7sN2ZqnPzYMgJw/sVw5WnPtP0ICWcvAuw4+ff1+fIUG3a K2BxfXA0YfE06vu6vXXxCKV+gB828NMFMiLzGMdJozwydmDEcXyjbztidTwKTFQ1d7Rw /HYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756238496; x=1756843296; 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=e0HjihKBKYS7LMayU8nqqILOVyz/HmjlESnRzdUsLDw=; b=mIUWd4i3vCSfKIVbrvLYX5kld4pa5r4XepoKuaRqkuVS3YWUdNqmPq/MhKHVJJghdl 3egGWVGlAn6fipSuhNdrpSQ2mUdQ9XvqLD0wDgQZvpQIlAby+xx1+NOTCSq8S4ivJ26h HCNC/Py82WvSm7EjWZz8Uta2fpi4wXNJmJenqLclclvvjYmbZ9ZMkmqJs7heSt7vrXlQ qZNe4tOnNfoVUh0mCB2kfcMRHoLN9drz8xvmuMn0dNdLIVtuT94gK4cV2QpYaistR2dm 9X4DHgno9hl31hbne4wNxHurg6RrHGzI2rUgz4RYAn09B0PqC1+oGYTy2/7o0CCviy2v ybBg== X-Forwarded-Encrypted: i=1; AJvYcCWeeEFGhsa0YhopKHAhjXZzpQaSApac6FMtfp/N6TRij5ErVyvYwAGsg2XjWjV1w4CPABIxY2BxKFyzIZXo@lists.postgresql.org X-Gm-Message-State: AOJu0YwGCP+1+qFJ3jdngANWXFvUGfApjokJEkjfhUB6NhMo8TwgJbJM QRAcAykqReHZ4XyxiN3/pSS9TO18FtxHs7epy3YnXbLyEsecicYIc/QBsMwyPwO4ud17das2Le1 2UzNGbJuEnGq1iqQXlfh93PXTAvdW59c= X-Gm-Gg: ASbGnct/5hxMIA0btD018aNEvIne+P1hL/A1NZvpsjTJr3MuUvc9ERyEz3stk9iPUyc 3+JxjKFVK7Ls2vUriujTdwiXXHbg95P/WhqOB5s3p9zjAPm5OIAGR+Cj5lq8Zwa2NPeVO1FL1i3 qKdHpxSfKQoupHbk5neSbfI7yD1E/wuWv7UQrRYGAbogrkNw0w0NKcAR2W2tfOo3Hda+KY3ezTB xsXPrJr9FouQCo5pjjf X-Google-Smtp-Source: AGHT+IFfzncqcYbkHnwM+7qHWPag7RYdve09f745B5i6UY0jiuHvJb24ohAV5AcKVS4V0Zg9/PyrBR8jXq7+rEP5CGc= X-Received: by 2002:a05:622a:1116:b0:4ab:3963:c650 with SMTP id d75a77b69052e-4b2e76f6fc9mr31173631cf.10.1756238495645; Tue, 26 Aug 2025 13:01:35 -0700 (PDT) MIME-Version: 1.0 References: <87DD95AA-274F-4F4F-BAD9-7738E5B1F905@yandex-team.ru> In-Reply-To: From: Kirill Reshke Date: Wed, 27 Aug 2025 01:01:24 +0500 X-Gm-Features: Ac12FXzYeckIdbWq6JzNjFsQq-mWhWvxThwJDyH-hmCBvjrVRqcGeplMrg_7w5g Message-ID: Subject: Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access) To: Melanie Plageman 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 Sat, 2 Aug 2025 at 02:36, Melanie Plageman w= rote: > > On Thu, Jul 31, 2025 at 6:58=E2=80=AFPM Melanie Plageman > wrote: > > > > The patch "Set-pd_prune_xid-on-insert.txt" can be applied as the last > > patch in the set. It sets pd_prune_xid on insert (so pages filled by > > COPY or insert can also be set all-visible in the VM before they are > > vacuumed). I gave it a .txt extension because it currently fails > > 035_standby_logical_decoding due to a recovery conflict. I need to > > investigate more to see if this is a bug in my patch set or elsewhere > > in Postgres. > > I figured out that if we set the VM on-access, we need to enable > hot_standby_feedback in more places in 035_standby_logical_decoding.pl > to avoid recovery conflicts. I've done that in the attached updated > version 6. There are a few other issues in > 035_standby_logical_decoding.pl that I reported here [1]. With these > changes, setting pd_prune_xid on insert passes tests. Whether or not > we want to do it (and what the heuristic should be for deciding when > to do it) is another question. > > - Melanie > > [1] https://www.postgresql.org/message-id/flat/CAAKRu_YO2mEm%3DZWZKPjTMU%= 3DgW5Y83_KMi_1cr51JwavH0ctd7w%40mail.gmail.com 0002 No comments from me. Looks straightforward. Few comments on 0003. 1) This patch introduces XLHP_HAS_VMFLAGS. However it lacks some helpful comments about this new status bit. a) In heapam_xlog.h, in xl_heap_prune struct definition: /* * If XLHP_HAS_CONFLICT_HORIZON is set, the conflict horizon XID follows, * unaligned */ + /* If XLHP_HAS_VMFLAGS is set, newly set visibility map bits comes, unaligned */ b) we can add here comment why we use memcpy assignment, akin to /* memcpy() because snapshot_conflict_horizon is stored unaligned */ + /* Next are the optionally included vmflags. Copy them out for later use.= */ + if ((xlrec.flags & XLHP_HAS_VMFLAGS) !=3D 0) + { + memcpy(&vmflags, maindataptr, sizeof(uint8)); + maindataptr +=3D sizeof(uint8); 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? 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, + --=20 Best regards, Kirill Reshke