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 1o9hTe-0007C9-2e for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Jul 2022 06:28:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o9hSe-0008DD-Nd for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Jul 2022 06:27:32 +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 1o9hSe-0008D4-B9 for pgsql-hackers@lists.postgresql.org; Fri, 08 Jul 2022 06:27:32 +0000 Received: from mail-yw1-x1134.google.com ([2607:f8b0:4864:20::1134]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1o9hSc-0004Lw-3T for pgsql-hackers@lists.postgresql.org; Fri, 08 Jul 2022 06:27:31 +0000 Received: by mail-yw1-x1134.google.com with SMTP id 00721157ae682-31cac89d8d6so120272207b3.2 for ; Thu, 07 Jul 2022 23:27:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TrNgy6PLt9VSoMgUbpbVI5C63psGpKV0SfgVxkKw3LM=; b=XgUFTcWFhQczaPYhnx8/BycG0bOfcoMcGrnjkFB1AHKE8UihyA+r8ek6/gKPLZQcLq s+YkfKT30pJ0dUyosWeku/pmzBqHkjzCDoHcLQzT8uO2AHaV1Zsfm8Q0xndNwf6937Wc Jj/xGBhJwfGpc/wraOXZ6Jn9qaMzMK+BjlWvH8ypxm0QhEohAtw3xNgyu/CVRHofVggV MlcnwNnunceXAq+8fco/6yrdJ2v7ihcGNNE0M00DhpWsr9AMx9U4MvN3vqcAzZq/3pKt +iGXAQWrgDTSjWZCdt4q7y90XbAPD7Tz71JEHvOAy68QVN4VV6YGMnoJK3mR3VYmJADU CQrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TrNgy6PLt9VSoMgUbpbVI5C63psGpKV0SfgVxkKw3LM=; b=43o61EUzd12UAfMgz6P9zNzCpNUD8lGM0Uw4vaVZr3BQxrI9nupgrUXSUIIrNrfrV8 aauxTLjGD8dI4OF2VnyDP7ERhIgsL0q/zq/rc6aKIopM8RxmXGIXV3hIFR+wQyTGLT6E L7U9umK8bSaAcUq7bgcWF9/CoynE/JPwvlki5dLhp4vEnPaKy4L+jb8ZjwXUAGx1y2am +Oa/eO77tFWuIthE8T766SElEkKkrjGXgG+6Z6C8MmYka4ONcDaE6wbpiwANRLjfeou5 O1bzkL/3NoBkkT2++abJDT0U5fnRbzyWDLMa+IXtQHPp8nTjQK+8qP4mAQuPr6WE9H0/ aNfQ== X-Gm-Message-State: AJIora9/u3J80HXmNnUGYQK7ckLK6y6KQ+4vC47tLu04aZ30utjImaZA BGbBCPowrSMmqmFLwAskwrg2nDx8VmAOZCTP32s= X-Google-Smtp-Source: AGRyM1vRjSUKttJK7GzUeIT6idsmqfVfHyq1SBsSkS+xG4ArIz9dj5LN1gLUFYfn5DBk7eQqXSMPTFVD/4kcwEWsmqQ= X-Received: by 2002:a81:3a56:0:b0:31d:64e:f818 with SMTP id h83-20020a813a56000000b0031d064ef818mr2198973ywa.223.1657261649207; Thu, 07 Jul 2022 23:27:29 -0700 (PDT) MIME-Version: 1.0 References: <20211008.165055.1621145185927268721.horikyota.ntt@gmail.com> <20220523.133323.444599955292141474.horikyota.ntt@gmail.com> In-Reply-To: From: Amit Kapila Date: Fri, 8 Jul 2022 11:57:17 +0530 Message-ID: Subject: Re: [BUG] Logical replication failure "ERROR: could not map filenode "base/13237/442428" to relation OID" with catalog modifying txns To: Masahiko Sawada Cc: Kyotaro Horiguchi , "Drouvot, Bertrand" , PostgreSQL Hackers , "Oh, Mike" Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Jul 8, 2022 at 6:45 AM Masahiko Sawada wrote: > > On Thu, Jul 7, 2022 at 3:40 PM Amit Kapila wrote: > > > > On Thu, Jul 7, 2022 at 8:21 AM Masahiko Sawada wrote: > > I've attached the new version patch that incorporates the comments and > the optimizations discussed above. > Thanks, few minor comments: 1. In ReorderBufferGetCatalogChangesXacts(), isn't it better to use the list length of 'catchange_txns' to allocate xids array? If we can do so, then we will save the need to repalloc as well. 2. /* ->committed manipulation */ static void SnapBuildPurgeCommittedTxn(SnapBuild *builder); The above comment also needs to be changed. 3. As SnapBuildPurgeCommittedTxn() removes xacts both from committed and catchange arrays, the function name no more remains appropriate. We can either rename to something like SnapBuildPurgeOlderTxn() or move the catchange logic to a different function and call it from SnapBuildProcessRunningXacts. 4. + if (TransactionIdEquals(builder->catchange.xip[off], + builder->xmin) || + NormalTransactionIdFollows(builder->catchange.xip[off], + builder->xmin)) Can we use TransactionIdFollowsOrEquals() instead of above? 5. Comment change suggestion: /* * Remove knowledge about transactions we treat as committed or containing catalog * changes that are smaller than ->xmin. Those won't ever get checked via - * the ->committed array and ->catchange, respectively. The committed xids will - * get checked via the clog machinery. + * the ->committed or ->catchange array, respectively. The committed xids will + * get checked via the clog machinery. We can ideally remove the transaction + * from catchange array once it is finished (committed/aborted) but that could + * be costly as we need to maintain the xids order in the array. */ Apart from the above, I think there are pending comments for the back-branch patch and some performance testing of this work. -- With Regards, Amit Kapila.