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 1nbI66-0007Fr-3V for pgsql-hackers@arkaria.postgresql.org; Mon, 04 Apr 2022 08:30:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nbI65-0000kG-0y for pgsql-hackers@arkaria.postgresql.org; Mon, 04 Apr 2022 08:30:01 +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 1nbI64-0000k6-Md for pgsql-hackers@lists.postgresql.org; Mon, 04 Apr 2022 08:30:00 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nbI5y-0003y9-Dn for pgsql-hackers@postgresql.org; Mon, 04 Apr 2022 08:30:00 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d15so2188040pll.10 for ; Mon, 04 Apr 2022 01:29:53 -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=pqBkufOXtEC9lzP1Ct5VkX1hDbXYEtBMd84Rl9h5NNE=; b=kCCe3AXAlqZylMx1FfJl0yJi+XrwW7HRHXySvMcmSK2ew7tQ559vNNQjlecrYeDbnN o3QXosWtEiE2WFCwlD8vG/aOruKtwHfRJkXHsUuVdTrivZc2cn+I2ESya7uCrqufWzyV 3ne1i/aIkuCXDWzhPypo3rMvmsjClloDRdzLHtyrFaRhrcAlkZYhCTPE58Loy4Q0kcBW VgohDJAaDfZ5frSuQCMe1PByqY/ng80C7U047OAQ+Wah2gXGvxEyrwghfzWuj4p8WoXD f3vzk7GqwxwB0rtGJ3IrCy4E2SRnPMBf6Q8GinhOfkgqaQI2FB0aZRdxOs6L7chjV7aQ FXIw== 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=pqBkufOXtEC9lzP1Ct5VkX1hDbXYEtBMd84Rl9h5NNE=; b=R7u//+QxYWN79Qx9Oc29CnjKkKOC3VIHws+5BxCSPcQDe6v6WtaQBRqQYUrclKbwya nSZTnuv5wLBVkKNKwO92Ec75wKOILyAUwdJJXuy0jqTZitffj+xpe+bia4Z0QkBp9mbG nAMwtBx8RclxiSdjQmFYVzv8Lh3yTE01zbXnKHkdFySAfFBNVFXzeYba9zQHl6LjUo+p ufPqvWfcFzuSrTUkHoFegknZaw8/Auj3tlbpln3KUjQVt4nBB5DGpBgZKhFtLxd91kYl gaZR1HA7dJycWRB+pRfFRnpEEFYD8EmZYah41EDGGPVXty2YzpKgqyxg3yQZH8KrPrWR Q5gg== X-Gm-Message-State: AOAM531LPd1RFL3q8Cla+B3UEwc1BnGCezYQ2LqluafUpTzRJD8vwFY9 6VZznYP98Xf4R9H8t9RWJ70= X-Google-Smtp-Source: ABdhPJxLLj+AZNpUlau2NUyzC6Y3pZGv/BLwHmIuoBtBne4CX1YcGcBu3G9qLtqQ3VM7WzcMQ3bbiA== X-Received: by 2002:a17:90b:4d08:b0:1c7:7567:9f6b with SMTP id mw8-20020a17090b4d0800b001c775679f6bmr25559114pjb.134.1649060992216; Mon, 04 Apr 2022 01:29:52 -0700 (PDT) Received: from localhost (KD036014041111.ppp-bb.dion.ne.jp. [36.14.41.111]) by smtp.gmail.com with ESMTPSA id d21-20020a056a0024d500b004fb0e7c7c3bsm11890014pfv.161.2022.04.04.01.29.49 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 04 Apr 2022 01:29:51 -0700 (PDT) Date: Mon, 04 Apr 2022 17:29:48 +0900 (JST) Message-Id: <20220404.172948.678193664696814690.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: <20220401.132157.1998467224568735059.horikyota.ntt@gmail.com> 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 Fri, 1 Apr 2022 14:51:58 -0400, Robert Haas wrote in > On Fri, Apr 1, 2022 at 12:22 AM Kyotaro Horiguchi > wrote: > > By the way, may I ask how do we fix this? The existing recovery code > > already generates just-to-be-delete files in a real directory in > > pg_tblspc sometimes, and elsewise skip applying WAL records on > > nonexistent heap pages. It is the "mixed" way. > > Can you be more specific about where we have each behavior now? They're done in XLogReadBufferExtended. The second behavior happens here, xlogutils.c: > /* hm, page doesn't exist in file */ > if (mode == RBM_NORMAL) > { > log_invalid_page(rnode, forknum, blkno, false); + Assert(0); > return InvalidBuffer; With the assertion, 015_promotion_pages.pl crashes. This prevents page creation and the following redo action on the page. The first behavior is described as the following comment: > * Create the target file if it doesn't already exist. This lets us cope > * if the replay sequence contains writes to a relation that is later > * deleted. (The original coding of this routine would instead suppress > * the writes, but that seems like it risks losing valuable data if the > * filesystem loses an inode during a crash. Better to write the data > * until we are actually told to delete the file.) > */ > smgrcreate(smgr, forknum, true); Without the smgrcreate call, make check-world fails due to missing files for FSM and visibility map, and init forks, which it's a bit doubtful that the cases fall into the category so-called "creates inexistent objects by redo access". In a few places, XLOG_FPI records are used to create the first page of a file including main and init forks. But I don't see a case of main fork during make check-world. # Most of the failure cases happen as standby freeze. I was a bit # annoyed that make check-world doesn't tell what is the module # currently being tested. In that case I had to deduce it from the # sequence of preceding script names, but if the first TAP script of a # module freezes, I had to use ps to find the module.. > > 1. stop XLogReadBufferForRedo creating a file in nonexistent > > directories then remember the failure (I'm not sure how big the > > impact is.) > > > > 2. unconditionally create all objects required for recovery to proceed.. > > 2.1 and igore the failures. > > 2.2 and remember the failures. > > > > 3. Any other? > > > > 2 needs to create a real directory in pg_tblspc. So 1? > > I think we could either do 1 or 2. My intuition is that getting 2 > working would be less scary and more likely to be something we would > feel comfortable back-patching, but 1 is probably a better design in > the long term. However, I might be wrong -- that's just a guess. Thanks. I forgot to mention in the previous mail (but mentioned somewhere upthread) but if we take 2, there's no way other than creating a real directory in pg_tblspc while recovery. I don't think it is neat. I haven't found how the patch caused creation of a relation file that is to be removed soon. However, I find that v19 patch fails by maybe due to some change in Cluster.pm. It takes a bit more time to check that.. regards. -- Kyotaro Horiguchi NTT Open Source Software Center