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 1oJivu-0001Or-Cl for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Aug 2022 22:03:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oJivt-0001N9-6t for pgsql-hackers@arkaria.postgresql.org; Thu, 04 Aug 2022 22:03:09 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oJivs-0001Ga-Sj for pgsql-hackers@lists.postgresql.org; Thu, 04 Aug 2022 22:03:08 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oJivq-0008W9-MU for pgsql-hackers@lists.postgresql.org; Thu, 04 Aug 2022 22:03:07 +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 274M2onX3663920; Thu, 4 Aug 2022 18:02:50 -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: References: <20220802175043.GA13682@telsasoft.com> <2767668.1659476794@sss.pgh.pa.us> <20220802220416.GC13682@telsasoft.com> <20220802222334.umf5wsa2r63koppn@awork3.anarazel.de> Comments: In-reply-to Robert Haas message dated "Thu, 04 Aug 2022 16:07:01 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3663918.1659650570.1@sss.pgh.pa.us> Date: Thu, 04 Aug 2022 18:02:50 -0400 Message-ID: <3663919.1659650570@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Robert Haas writes: > I have reviewed this patch and I don't see a problem with it. However, > it would be nice if Andres or someone else who understands this area > well (Tom? Thomas?) would also review it, because I also reviewed > what's in the tree now and that turns out to be buggy, which leads me > to conclude that I don't understand this area as well as would be > desirable. FWIW, I approve of getting rid of the use of CreateFakeRelcacheEntry here, because I do not think that mechanism is meant to be used outside of WAL replay. However, this patch fails to remove it from CreateAndCopyRelationData, which seems likely to be just as much at risk. The "invalidation" comment bothered me for awhile, but I think it's fine: we know that no other backend can connect to the source DB because we have it locked, and we know that no other backend can connect to the destination DB because it doesn't exist yet according to the catalogs, so nothing could possibly occur to invalidate our idea of where the physical files are. It would be nice to document these assumptions, though, rather than merely remove all the relevant commentary. While I'm at it, I would like to strenuously object to the current framing of CreateAndCopyRelationData as a general-purpose copying mechanism. Because of the above assumptions, I think it's utterly unsafe to use anywhere except in CREATE DATABASE. The header comment fails to warn about that at all, and placing it in bufmgr.c rather than static in dbcommands.c is just an invitation to future misuse. Perhaps I'm overly sensitive to that because I just finished cleaning up somebody's misuse of non-general-purpose code (1aa8dad41), but as this stands I think it's positively dangerous. regards, tom lane