pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #19894: CREATE DATABASE logs all-zeros visibility map
4+ messages / 3 participants
[nested] [flat]

* BUG #19894: CREATE DATABASE logs all-zeros visibility map
@ 2026-11-12 00:49 PG Bug reporting form <noreply@postgresql.org>
  2026-11-12 06:51 ` Re: BUG #19894: CREATE DATABASE logs all-zeros visibility map Сергей Шиндерук <s.shinderuk@postgrespro.ru>
  2026-11-12 17:40 ` Re: BUG #19894: CREATE DATABASE logs all-zeros visibility map Christophe Pettus <xof@thebuild.com>
  0 siblings, 2 replies; 4+ messages in thread

From: PG Bug reporting form @ 2026-11-12 00:49 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: s.shinderuk@postgrespro.ru

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 ^ permalink raw reply [nested|flat] 4+ messages in thread

* Re: BUG #19894: CREATE DATABASE logs all-zeros visibility map
  2026-11-12 00:49 BUG #19894: CREATE DATABASE logs all-zeros visibility map PG Bug reporting form <noreply@postgresql.org>
@ 2026-11-12 06:51 ` Сергей Шиндерук <s.shinderuk@postgrespro.ru>
  1 sibling, 0 replies; 4+ messages in thread

From: Сергей Шиндерук @ 2026-11-12 06:51 UTC (permalink / raw)
  To: s.shinderuk@postgrespro.ru; pgsql-bugs@lists.postgresql.org


> 12 нояб. 2026 г., в 03:49, PG Bug reporting form <noreply@postgresql.org> написал(а):
> 
> 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)


Sorry, looks like it's a known issue:
https://www.postgresql.org/message-id/CAAKRu_bK7oJvtrrzL_V-OHouCWDKyU2-ERv+QvV6XM9Wh2dpUg@mail.gmail...
https://www.postgresql.org/message-id/CAAKRu_aaP%3D0GZe%2BD721byOM9Vwjtu94VdAE_em0PNC0r3EK2zg%40mail...

Didn't follow the discussion yet.





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: BUG #19894: CREATE DATABASE logs all-zeros visibility map
  2026-11-12 00:49 BUG #19894: CREATE DATABASE logs all-zeros visibility map PG Bug reporting form <noreply@postgresql.org>
@ 2026-11-12 17:40 ` Christophe Pettus <xof@thebuild.com>
  2026-11-12 18:18   ` Re: BUG #19894: CREATE DATABASE logs all-zeros visibility map Сергей Шиндерук <s.shinderuk@postgrespro.ru>
  1 sibling, 1 reply; 4+ messages in thread

From: Christophe Pettus @ 2026-11-12 17:40 UTC (permalink / raw)
  To: s.shinderuk@postgrespro.ru; pgsql-bugs@lists.postgresql.org



> 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)


Why is this a bug?






^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: BUG #19894: CREATE DATABASE logs all-zeros visibility map
  2026-11-12 00:49 BUG #19894: CREATE DATABASE logs all-zeros visibility map PG Bug reporting form <noreply@postgresql.org>
  2026-11-12 17:40 ` Re: BUG #19894: CREATE DATABASE logs all-zeros visibility map Christophe Pettus <xof@thebuild.com>
@ 2026-11-12 18:18   ` Сергей Шиндерук <s.shinderuk@postgrespro.ru>
  0 siblings, 0 replies; 4+ messages in thread

From: Сергей Шиндерук @ 2026-11-12 18:18 UTC (permalink / raw)
  To: Christophe Pettus <xof@thebuild.com>; +Cc: pgsql-bugs@lists.postgresql.org


> 12 нояб. 2026 г., в 20:40, Christophe Pettus <xof@thebuild.com> написал(а):
> 
>> 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)
> 
> 
> Why is this a bug?


I'm sorry for bothering you. It's already discussed here:
https://www.postgresql.org/message-id/tencent_2E870046716FD94285045E96505A2D4E2908@qq.com
and here, causing data corruption:
https://www.postgresql.org/message-id/CAAKRu_bK7oJvtrrzL_V-OHouCWDKyU2-ERv+QvV6XM9Wh2dpUg@mail.gmail...

I should have searched hackers before submitting a bug :(







^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2026-11-12 18:18 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-12 00:49 BUG #19894: CREATE DATABASE logs all-zeros visibility map PG Bug reporting form <noreply@postgresql.org>
2026-11-12 06:51 ` Сергей Шиндерук <s.shinderuk@postgrespro.ru>
2026-11-12 17:40 ` Christophe Pettus <xof@thebuild.com>
2026-11-12 18:18   ` Сергей Шиндерук <s.shinderuk@postgrespro.ru>

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