pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: s.shinderuk@postgrespro.ru
Subject: BUG #19894: CREATE DATABASE logs all-zeros visibility map
Date: Thu, 12 Nov 2026 00:49:22 +0000
Message-ID: <19894-9d785d87407234dc@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      19894
Logged by:          Sergey Shinderuk
Email address:      s.shinderuk@postgrespro.ru
PostgreSQL version: 17.11
Operating system:   Ubuntu 24.04
Description:        

Hello,

after CREATE DATABASE on a primary
select * from pg_visibility_map('pg_class')
 blkno | all_visible | all_frozen
-------+-------------+------------
     0 | t           | t
     1 | t           | t
     2 | t           | t
     3 | t           | t
     4 | t           | t
     5 | t           | t
     6 | t           | t
     7 | t           | t
     8 | t           | t
     9 | t           | t
    10 | t           | t
    11 | t           | t
    12 | t           | t
    13 | t           | t
(14 rows)

but on a standby:
 blkno | all_visible | all_frozen
-------+-------------+------------
     0 | f           | f
     1 | f           | f
     2 | f           | f
     3 | f           | f
     4 | f           | f
     5 | f           | f
     6 | f           | f
     7 | f           | f
     8 | f           | f
     9 | f           | f
    10 | f           | f
    11 | f           | f
    12 | f           | f
    13 | f           | f
(14 rows)

In the WAL:
rmgr: Storage     len (rec/tot):     42/    42, tx:        738, lsn:
0/018177E0, prev 0/01817790, desc: CREATE base/16384/1259_vm
rmgr: XLOG        len (rec/tot):     49/    73, tx:        738, lsn:
0/01817810, prev 0/018177E0, desc: FPI
        blkref #0: rel 1663/16384/1259 fork vm blk 0 (FPW); hole: offset:
24, length: 8168

VM FPI is just a page header, all the rest is a hole.

I think this fixes the bug:
----------------------------------------
inline patch 1: src/backend/storage/buffer/bufmgr.c (+0/-0 lines) download inline-1.patch--- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -4834,7 +4834,7 @@ RelationCopyStorageUsingBuffer(RelFileLocator
srclocator, /* WAL-log the copied page. */ if (use_wal) - log_newpage_buffer(dstBuf, true); + log_newpage_buffer(dstBuf, forkNum != VISIBILITYMAP_FORKNUM); END_CRIT_SECTION(); ---------------------------------------- With this patch: rmgr: Storage len (rec/tot): 42/ 42, tx: 738, lsn: 0/018257E0, prev 0/01825790, desc: CREATE base/16384/1259_vm rmgr: XLOG len (rec/tot): 49/ 8241, tx: 738, lsn: 0/01825810, prev 0/018257E0, desc: FPI blkref #0: rel 1663/16384/1259 fork vm blk 0 (FPW); hole: offset: 0, length: 0 I was comparing pgdata contents on a primary and a standby after 027_stream_regress and noticed that visibility maps strangely don't match. Repo script: ---------------------------------------- #!/bin/sh rm -rf primary standby rm -f initdb.log primary.log standby.log initdb -D primary > initdb.log cp -a primary standby touch standby/standby.signal cat > standby/postgresql.auto.conf <<EOF port = 5433 primary_conninfo = 'port=5432' EOF pg_ctl -D primary -l primary.log start pg_ctl -D standby -l standby.log start createdb demo psql -d demo -c "create extension pg_visibility" psql -d demo -c "select * from pg_visibility_map('pg_class')" sleep 1 psql -p 5433 -d demo -c "select * from pg_visibility_map('pg_class')" pg_ctl -D primary stop pg_ctl -D standby stop ---------------------------------------- Best regards, Sergey

view thread (4+ messages)  latest in thread

Message-ID: <19894-9d785d87407234dc@postgresql.org>
Permalink:  ../19894-9d785d87407234dc@postgresql.org/
Also on:    postgresql.org/message-id/19894-9d785d87407234dc@postgresql.org

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, s.shinderuk@postgrespro.ru
  Subject: Re: BUG #19894: CREATE DATABASE logs all-zeros visibility map
  In-Reply-To: <19894-9d785d87407234dc@postgresql.org>
  References: <19894-9d785d87407234dc@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox