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 1nZ3tP-0006ot-UQ for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Mar 2022 04:55:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nZ3tO-0002wt-RC for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Mar 2022 04:55:42 +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 1nZ3tO-0002wk-Fn for pgsql-hackers@lists.postgresql.org; Tue, 29 Mar 2022 04:55:42 +0000 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nZ3tM-0000wB-0j for pgsql-hackers@postgresql.org; Tue, 29 Mar 2022 04:55:41 +0000 Received: by mail-pg1-x529.google.com with SMTP id t4so10795962pgc.1 for ; Mon, 28 Mar 2022 21:55:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:message-id:to:cc:subject:from:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=dYRapJgv1mVOjP2Tk9uAePhMTpW5aCpZyBHx4xpjFeM=; b=ESx+lNOYk1hZOeRCgaLO3UxVG7yO4XbnLu6hI3jum+jgyDmH19VBx2nIsltT+erli2 /zzHj150r+9xxRxf60mFje1hysRMgG8hVYWA63D2/sR34AAAtBe7Que29cfOIMx38sqM I+L01R48v5TeSJzwrN2wM4EM3O02NWi6U7PWVD6ergA2ao06yPUxgp0yP8q0H0y3kYNH 0AWZGmMwz42kZDj2CoMud9h1FtLQDy6l7DhYbt/2tCLs8mPbcPZmIFJWwl6c47bFqJcd 6iWphu4JOdFcG8O2+w/PgCmp5mWKr3aSrEApsrZgBAkk0QRb/MKUab63m2uVSw1OeS3Y 88gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:to:cc:subject:from:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=dYRapJgv1mVOjP2Tk9uAePhMTpW5aCpZyBHx4xpjFeM=; b=Js+KQgPqSVqAHhQc8t8a2lczgDVCZeXexzbYTYdpkI7KyYA7qoDbsjLpQFokGUJXGg 9FCtDm5B49QVbfW4bUnTzN+tKLnDV2vZpGPyeLH6bWWJZ8v+CTze1T/GqfGZqRfHNdwq ZrO98xbg1wKR9BeEJEbqbPimFuf8YO3F3naZY513l39uu3ICH55q5pU/W+kkR+H3LdXm 8O+uSZxF1fBGWegQ6/IFfFpkS0tcx0ogoxQh81aY+e9Pu2Ra9Q9aMCvIJgamkFGEpkKk qc9ztoKovrpuPT2vXPP7AujNXR3pfRLGDzoIJVI47YmOCLyWfeg3/m0JGUGAJqY9A/uh UQzQ== X-Gm-Message-State: AOAM532jbj+CnuSCJBweZ6K3vC2Jv1QD01Th4eo+CMR485SUBC44H0Fm YoSJJlAfl1hnHrlTP+2evsE= X-Google-Smtp-Source: ABdhPJxYMCoMTEwA028FD225sHoHZZFp1bR95fk01lBKI1R9JOz5tPHZQQ9bh5FS/tvzScqB3MUTNg== X-Received: by 2002:a63:6f85:0:b0:398:3e74:bdd8 with SMTP id k127-20020a636f85000000b003983e74bdd8mr676491pgc.423.1648529738621; Mon, 28 Mar 2022 21:55:38 -0700 (PDT) Received: from localhost (KD036014041111.ppp-bb.dion.ne.jp. [36.14.41.111]) by smtp.gmail.com with ESMTPSA id h2-20020a056a00218200b004f6519ce666sm18284683pfi.170.2022.03.28.21.55.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 28 Mar 2022 21:55:37 -0700 (PDT) Date: Tue, 29 Mar 2022 13:55:35 +0900 (JST) Message-Id: <20220329.135535.310000883119475499.horikyota.ntt@gmail.com> To: robertmhaas@gmail.com Cc: alvherre@alvh.no-ip.org, michael@paquier.xyz, rjuju123@gmail.com, pgsql-hackers@postgresql.org Subject: Re: standby recovery fails (tablespace related) (tentative patch and discussion) From: Kyotaro Horiguchi In-Reply-To: References: <202203211903.ni5vfpmyelk7@alvherre.pgsql> User-Agent: Mew version 6.8 on Emacs 26.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk At Mon, 28 Mar 2022 12:17:50 -0400, Robert Haas wrote in > On Mon, Mar 21, 2022 at 3:02 PM Alvaro Herrera wrote: > > > 2. Why not instead change the code so that the operation can succeed, > > > by creating the prerequisite parent directories? Do we not have enough > > > information for that? I'm not saying that we definitely should do it > > > that way rather than this way, but I think we do take that approach in > > > some cases. > > > > It seems we can choose freely between these two implementations -- I > > mean I don't see any upsides or downsides to either one. > > What got committed here feels inconsistent to me. Suppose we have a > checkpoint, and then a series of operations that touch a tablespace, > and then a drop database and drop tablespace. If the first operation > happens to be CREATE DATABASE, then this patch is going to fix it by > skipping the operation. However, if the first operation happens to be > almost anything else, the way it's going to reference the dropped > tablespace is via a block reference in a WAL record of a wide variety > of types. That's going to result in a call to > XLogReadBufferForRedoExtended() which will call > XLogReadBufferExtended() which will do smgrcreate(smgr, forknum, true) > which will in turn call TablespaceCreateDbspace() to fill in all the > missing directories. Right. I thought that recovery avoids that but that's wrong. This behavior creates a bare (non-linked) directly within pg_tblspc. The directory would dissapear soon if recovery proceeds to the consistency point, though. > I don't think that's very good. It would be reasonable to decide that > we're never going to create the missing directories and instead just > remember that they were not found so we can do a cross check. It's > also reasonable to just create the directories on the fly. But doing a > mix of those systems doesn't really seem like the right idea - > particularly because it means that the cross-check system is probably > not very effective at finding actual problems in the code. > > Am I missing something here? No. I agree that mixing them is not good. On the other hand we already doing that by heapam. AFAICS sometimes it avoid creating a new page but sometimes creates it. But I don't mean to use the fact for justifying this patch to do that, or denying to do that. regards. -- Kyotaro Horiguchi NTT Open Source Software Center