| From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Cc: | s(dot)shinderuk(at)postgrespro(dot)ru |
| Subject: | BUG #19894: CREATE DATABASE logs all-zeros visibility map |
| Date: | 2026-11-12 00:49:22 |
| Message-ID: | 19894-9d785d87407234dc@postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 19894
Logged by: Sergey Shinderuk
Email address: s(dot)shinderuk(at)postgrespro(dot)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:
----------------------------------------
--- 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Amit Langote | 2026-11-12 01:23:15 | Re: BUG #19625: SQL/JSON boolean DEFAULT expression silently replaced with 'false' |
| Previous Message | Michael Paquier | 2026-11-11 22:40:47 | Re: BUG #19857: Stats restore rejects empty arrays, losing range and array stats |