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 1mZs3j-0000hJ-Tq for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Oct 2021 09:57:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mZrrP-0006TV-Ni for pgsql-hackers@arkaria.postgresql.org; Mon, 11 Oct 2021 09:44:43 +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 1mZrrP-0006TL-CE for pgsql-hackers@lists.postgresql.org; Mon, 11 Oct 2021 09:44:43 +0000 Received: from smtp-fw-2101.amazon.com ([72.21.196.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mZrrL-0000fk-Eg for pgsql-hackers@lists.postgresql.org; Mon, 11 Oct 2021 09:44:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1633945479; x=1665481479; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=UDixFnvBL7mz46D/Uu0ZTES66IMNojJpPqjQgwsZ0Fk=; b=qQltrct4db9zftqlU1CWaT3DrRZxDFL5cHITwOgWyHpqyfyuRfYSkaN6 F6S/hxYLgQ6WTbKwS6ktaxhw8fgJ7dDwmuvE9ESddB52rM0DdWtMCEIpx utADO5u3qC8o/QIXxJszvWzszNH+j9U7eqqGIyY8Le9LHdVCTkJw4Mp/K I=; X-IronPort-AV: E=Sophos;i="5.85,364,1624320000"; d="scan'208";a="143679258" Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-iad-1d-10222bbc.us-east-1.amazon.com) ([10.43.8.2]) by smtp-border-fw-2101.iad2.amazon.com with ESMTP; 11 Oct 2021 09:44:29 +0000 Received: from EX13D03EUC003.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1d-10222bbc.us-east-1.amazon.com (Postfix) with ESMTPS id 3D1241A08D6; Mon, 11 Oct 2021 09:44:27 +0000 (UTC) Received: from [192.168.24.187] (10.43.162.148) by EX13D03EUC003.ant.amazon.com (10.43.164.192) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Mon, 11 Oct 2021 09:44:25 +0000 Message-ID: <89fbeef1-aebe-5f1c-b559-2ea8cb90dcbd@amazon.com> Date: Mon, 11 Oct 2021 11:44:21 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.1.2 Subject: Re: [BUG] Logical replication failure "ERROR: could not map filenode "base/13237/442428" to relation OID" with catalog modifying txns Content-Language: en-US To: Masahiko Sawada , Kyotaro Horiguchi CC: PostgreSQL Hackers , "Oh, Mike" References: <6a176936-1af1-41d9-9ded-bde0eb47dd5c@amazon.com> <20211008.165055.1621145185927268721.horikyota.ntt@gmail.com> From: "Drouvot, Bertrand" In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.43.162.148] X-ClientProxiedBy: EX13D08UWC004.ant.amazon.com (10.43.162.90) To EX13D03EUC003.ant.amazon.com (10.43.164.192) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 10/11/21 8:27 AM, Masahiko Sawada wrote: > On Fri, Oct 8, 2021 at 4:50 PM Kyotaro Horiguchi > wrote: >> At Thu, 7 Oct 2021 13:20:14 +0900, Masahiko Sawada wrote in >>> Another idea to fix this problem would be that before calling >>> SnapBuildCommitTxn() we create transaction entries in ReorderBuffer >>> for (sub)transactions whose COMMIT record has XACT_XINFO_HAS_INVALS, >>> and then mark all of them as catalog-changed by calling >>> ReorderBufferXidSetCatalogChanges(). I've attached a PoC patch for >>> this idea. What the patch does is essentially the same as what the >>> proposed patch does. But the patch doesn't modify the >>> SnapBuildCommitTxn(). And we remember the list of last running >>> transactions in reorder buffer and the list is periodically purged >>> during decoding RUNNING_XACTS records, eventually making it empty. >> I came up with the third way. SnapBuildCommitTxn already properly >> handles the case where a ReorderBufferTXN with >> RBTXN_HAS_CATALOG_CHANGES. So this issue can be resolved by create >> such ReorderBufferTXNs in SnapBuildProcessRunningXacts. > Thank you for the idea and patch! Thanks you both for your new patches proposal! I liked Sawada's one but also do "prefer" Horiguchi's one. > > It's much simpler than mine. I think that creating an entry of a > catalog-changed transaction in the reorder buffer before > SunapBuildCommitTxn() is the right direction. +1 > > After more thought, given DDLs are not likely to happen than DML in > practice, probably we can always mark both the top transaction and its > subtransactions as containing catalog changes if the commit record has > XACT_XINFO_HAS_INVALS? I believe this is not likely to lead to > overhead in practice. That way, the patch could be more simple and > doesn't need the change of AssertTXNLsnOrder(). > > I've attached another PoC patch. Also, I've added the tests for this > issue in test_decoding. Thanks! It looks good to me, just have a remark about the comment: +   /* +    * Mark the top transaction and its subtransactions as containing catalog +    * changes, if the commit record has invalidation message. This is necessary +    * for the case where we decode only the commit record of the transaction +    * that actually has done catalog changes. +    */ What about?     /*      * Mark the top transaction and its subtransactions as containing catalog      * changes, if the commit record has invalidation message. This is necessary      * for the case where we did not decode the transaction that did the catalog      * change(s) (the decoding restarted after). So that we are decoding only the      * commit record of the transaction that actually has done catalog changes.      */ Thanks Bertrand