Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oJjqE-0004OX-42 for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Aug 2022 23:01:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oJjqC-0000G2-Ud for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Aug 2022 23:01:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oJjqC-0000Fa-Kx for pgsql-hackers@lists.postgresql.org; Thu, 04 Aug 2022 23:01:20 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oJjq6-00062G-It for pgsql-hackers@lists.postgresql.org; Thu, 04 Aug 2022 23:01:20 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 274N16gl3679801; Thu, 4 Aug 2022 19:01:06 -0400 From: Tom Lane To: Robert Haas cc: Dilip Kumar , Andres Freund , Justin Pryzby , Ashutosh Sharma , Maciek Sakrejda , Bruce Momjian , Alvaro Herrera , Andrew Dunstan , Heikki Linnakangas , PostgreSQL Hackers , Thomas Munro Subject: Re: [Proposal] Fully WAL logged CREATE DATABASE - No Checkpoints In-reply-to: <3663919.1659650570@sss.pgh.pa.us> References: <20220802175043.GA13682@telsasoft.com> <2767668.1659476794@sss.pgh.pa.us> <20220802220416.GC13682@telsasoft.com> <20220802222334.umf5wsa2r63koppn@awork3.anarazel.de> <3663919.1659650570@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Thu, 04 Aug 2022 18:02:50 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3679799.1659654066.1@sss.pgh.pa.us> Date: Thu, 04 Aug 2022 19:01:06 -0400 Message-ID: <3679800.1659654066@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I wrote: > While I'm at it, I would like to strenuously object to the current > framing of CreateAndCopyRelationData as a general-purpose copying > mechanism. And while I'm piling on, how is this bit in RelationCopyStorageUsingBuffer not completely broken? /* Read block from source relation. */ srcBuf = ReadBufferWithoutRelcache(src->rd_locator, forkNum, blkno, RBM_NORMAL, bstrategy_src, permanent); srcPage = BufferGetPage(srcBuf); if (PageIsNew(srcPage) || PageIsEmpty(srcPage)) { ReleaseBuffer(srcBuf); continue; } /* Use P_NEW to extend the destination relation. */ dstBuf = ReadBufferWithoutRelcache(dst->rd_locator, forkNum, P_NEW, RBM_NORMAL, bstrategy_dst, permanent); You can't skip pages just because they are empty. Well, maybe you could if you were doing something to ensure that you zero-fill the corresponding blocks on the destination side. But this isn't doing that. It's using P_NEW for dstBuf, which will have the effect of silently collapsing out such pages. Maybe in isolation a heap could withstand that, but its indexes won't be happy (and I guess t_ctid chain links won't either). I think you should just lose the if() stanza. There's no optimization to be had here that's worth any extra complication. (This seems worth fixing before beta3, as it looks like a rather nasty data corruption hazard.) regards, tom lane