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 1pSRnu-0007s9-1W for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Feb 2023 00:07:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pSRnr-0007Ul-3y for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Feb 2023 00:07:11 +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 1pSRnq-0007UR-P9 for pgsql-hackers@lists.postgresql.org; Thu, 16 Feb 2023 00:07:10 +0000 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pSRnj-00087t-Qc for pgsql-hackers@lists.postgresql.org; Thu, 16 Feb 2023 00:07:09 +0000 Received: by mail-pf1-x432.google.com with SMTP id r17so371756pff.9 for ; Wed, 15 Feb 2023 16:07:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=wNzE/XgyYsJSGv2yiiAxihYGl/TvGqxsVWFKdII42T4=; b=iHlV1hj8xbQOrKI339X19DRO1VqQ6nlPL5d509SJ/YZN0658W+l8hc21UhA63omm4O cjFL9vsPdhxFibd29hIbe58kwj3x6cbDwJo0Zj1tU5t6k7SDUIvLDfYfU1crXTx7VcdF Yn6xqOwUdYJwf10PlhCm/EmL+wJp4PtoIOn7ZgJyJf+0/Z4fgZk73d0cDzmZCQXd9+tR raJjrxI8NMOM+d6N3iCCDJgsXfr23LrCE+Dz6CjyhKRvQzIa7w4zHxYcqQyCf6yuOD6v /dPnYSrE9z5Sl241D3xKgSIAXcmhsq3BszTzNBh1HmprRswOKXaZ/anMamEdnJpN3wxg fceg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=wNzE/XgyYsJSGv2yiiAxihYGl/TvGqxsVWFKdII42T4=; b=gkFS3DszBA06SkMHpbrrNly0igGLipqMCy+OQV2qiFTvOdO0EgUhSQIviTBXfmhXT3 RDRZQFPXuMwmlwFeNrDFwmtB0B3ZTW8JjOyPchK2T4PbcOZdrWjIlGlt+vzmAzPcsvC2 +5a0YuK+wE20mRDPgiyFg1djxrgiuUwVuodVQZKO6KT4oRDKMUclgzClYg1FM5fpI5v8 cpr3bsEneedKjeP41RphejBbPpNlPSRRM2VTS7JdRXTcaSmA7SOVZjTxJuQEjnnLAOvT bJH/se12Au+ztqmelOGUJRsZpGXSSAutCL2RDUYDz2AjkwbNMR9MxVgxL3I0LqazNs82 XM0w== X-Gm-Message-State: AO0yUKU2l4HovP9dJHajQY0K7pp93yPZ9MebYYrTpYf9+7uaCFlUn8qK I6Hml/nDfXEATowQ6+zSXPY= X-Google-Smtp-Source: AK7set83vKlKxpcUL4ks56N46it+ZHevKVw8OcuHuyuXOXfV3bkXDb5J3q6SgbHBNlxkz0A+Q0pzGA== X-Received: by 2002:aa7:97a3:0:b0:5a8:bdca:a82c with SMTP id d3-20020aa797a3000000b005a8bdcaa82cmr3509970pfq.29.1676506022548; Wed, 15 Feb 2023 16:07:02 -0800 (PST) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id u10-20020aa7848a000000b005895f9657ebsm12182712pfn.70.2023.02.15.16.07.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 16:07:01 -0800 (PST) Date: Wed, 15 Feb 2023 16:06:59 -0800 From: Nathan Bossart To: "Ryo Matsumura (Fujitsu)" Cc: PostgreSQL Hackers Subject: Re: DDL result is lost by CREATE DATABASE with WAL_LOG strategy Message-ID: <20230216000659.GA1932550@nathanxps13> References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="UlVJffcvxoiEqYs2" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --UlVJffcvxoiEqYs2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Feb 15, 2023 at 04:49:38AM +0000, Ryo Matsumura (Fujitsu) wrote: > The above is occured by the following call. > The argument 'permanent' of ReadBufferWithoutRelcache() is passed to > BufferAlloc() as 'relpersistence'. > > [src/backend/commands/] > 298 buf = ReadBufferWithoutRelcache(rnode, MAIN_FORKNUM, blkno, > 299 RBM_NORMAL, bstrategy, false); Indeed, setting that to true (as per the attached patch) seems to fix this. I don't see any reason this _shouldn't_ be true from what I've read so far. We're reading pg_class, which will probably never be UNLOGGED. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com --UlVJffcvxoiEqYs2 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="create_db_fix.patch" diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index ef05633bb0..a0259cc593 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -296,7 +296,7 @@ ScanSourceDatabasePgClass(Oid tbid, Oid dbid, char *srcpath) CHECK_FOR_INTERRUPTS(); buf = ReadBufferWithoutRelcache(rlocator, MAIN_FORKNUM, blkno, - RBM_NORMAL, bstrategy, false); + RBM_NORMAL, bstrategy, true); LockBuffer(buf, BUFFER_LOCK_SHARE); page = BufferGetPage(buf); --UlVJffcvxoiEqYs2--