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.98.2) (envelope-from ) id 1xRYdx-000000014uo-43Lb for pgsql-bugs@arkaria.postgresql.org; Thu, 12 Nov 2026 17:31:25 +0000 Received: from localhost ([127.0.0.1]:47730 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xRYds-0000000451F-1cnu for pgsql-bugs@arkaria.postgresql.org; Thu, 12 Nov 2026 17:31:20 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]:53464) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xRJ0x-0000000E0Tl-3f8I for pgsql-bugs@lists.postgresql.org; Thu, 12 Nov 2026 00:50:07 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xRJ0w-00000000Se8-2a2t for pgsql-bugs@lists.postgresql.org; Thu, 12 Nov 2026 00:50:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Message-ID:Date:Reply-To:Cc:From:To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:Sender:Content-ID: Content-Description:In-Reply-To:References; bh=ae34HdLxoDvMEhVdaTAGeqCR8jCFYtAE+3oGcq5GQ9U=; b=HQbFI2yR0BZIPkSdYthZztyrFD 667stwAxPDFTksRdIluFj8cOZlyhSfYqQxkXv2DHQOtXyqP+aBXhaHsmJnpBcVwcoICqxl6lhNWNf fGhBEuNeHnLeF5hkPDOsKG5887IhfVQzDHZ59sbdeBJhyn7Own0OenfyRepjQ1DNxWZWjewXZxmJz sr7B0+CPvbzHVHJREjFKIyXV3v9W+GUT7/sKmGVIJGFYvIFpJqUPxpc4pytF4o7/9nuUvoqdH4c8E DVXfUD7TJRK33tDacMdfn/fIOqSKL0j47FkPGBGkx9cJCYhH/GVIVJBVz/gUPHoS8/Sou2y+8tm35 7Y1bHnZQ==; Received: from wrigleys.postgresql.org ([2a02:16a8:dc51::60]) by mahout.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xRJ0u-00000001Gbp-1ngz for pgsql-bugs@lists.postgresql.org; Thu, 12 Nov 2026 00:50:06 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xRJ0t-00000003BQ2-0rOF for pgsql-bugs@lists.postgresql.org; Thu, 12 Nov 2026 00:50:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19894: CREATE DATABASE logs all-zeros visibility map To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: s.shinderuk@postgrespro.ru Reply-To: s.shinderuk@postgrespro.ru, pgsql-bugs@lists.postgresql.org Date: Thu, 12 Nov 2026 00:49:22 +0000 Message-ID: <19894-9d785d87407234dc@postgresql.org> X-Auto-Response-Suppress: All Auto-Submitted: auto-generated List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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: =20 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, =20 /* WAL-log the copied page. */ if (use_wal) - log_newpage_buffer(dstBuf, true); + log_newpage_buffer(dstBuf, forkNum !=3D VISIBILITYMAP_FORKNUM); =20 END_CRIT_SECTION(); =20 ---------------------------------------- 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 <