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 1oB4hy-0006Ry-2O for pgsql-hackers@arkaria.postgresql.org; Tue, 12 Jul 2022 01:29: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 1oB4hv-0006HJ-G1 for pgsql-hackers@arkaria.postgresql.org; Tue, 12 Jul 2022 01:28:59 +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 1oB4hv-0006HA-4i for pgsql-hackers@lists.postgresql.org; Tue, 12 Jul 2022 01:28:59 +0000 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oB4hs-0003i8-F6 for pgsql-hackers@lists.postgresql.org; Tue, 12 Jul 2022 01:28:58 +0000 Received: by mail-pj1-x1033.google.com with SMTP id b8so4894353pjo.5 for ; Mon, 11 Jul 2022 18:28:56 -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=owexUJz3y9hOLDeweA4fZc2S7DnvYPRgQcCexzQ/Lsw=; b=Z4sLiDRPJStnkJCvwxHhMqjyPnOIGa7tyk56gYL7lceCgeuQrWNYop9/E8fh7pehCn fJualpz0dTF0q1Df9MDDl7JJGt+28SQeeoFCcCZ1f5bpd0HAJpqWuf+PUYStMibPysjj GW540WBqsQbN7gQ0+BonUowZ9+nnsPCUB1HLcN4ZbjN97rpheOL3zIoihhGu0EEqkj8F pENI03dV7u84zi4c51K2FHm1I2isXbExd54Si95IklOu1KDXPaD5CV3vNXa5wIBuc/RY 015BaFPIK2pv4X8b8lI48wPHyaTXTTMzbvPwAveArD5/p5xoNcXNjGoRFjAv0deYMalw yK1g== 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=owexUJz3y9hOLDeweA4fZc2S7DnvYPRgQcCexzQ/Lsw=; b=0mrp64iSDFwPbunSx5MOLA9aDulu7a9sITo5lz+RkcFLErPLpL1Rw9UUP5nSBocB4S PjACX6PLUBUAZJl+f8mh8135MMRhBC9IubZt40XBe25+JTYfJS59MaVufIkry9IpxgnY T8xTRIbKszM9uH5mf2VRH/HQbNMh1RDc2FaqXGX78lDxBvdE1D4vJsgVmEh6lClEzDoL PjaqzNKbDIF7uYihLJLYm7gcaKKFzEQ2Z1j69G4vxb96lpmdYmzyC52eopoStJl3CLrs ZSP529ZbwrSGBnPNTEfraZYXi5N40HFwWXL303B289mP4ZbqrhmAThARbIAPTYH6hEkW /Feg== X-Gm-Message-State: AJIora+RQqq6eOgltc5y0qAG+kfeQFZ2CfFOYw4M9BDMcyhX+DuGPbj/ LFIEK+YvRWjQL/HpPHC+tEnxtMkGi3LubYmFOpc= X-Google-Smtp-Source: AGRyM1s3WiiMhRiVWl1xodAnEn4aKDRm5grjQfI55LWN02rQXPMaSv2C7bpOM40A11N1ni3k/xc7HxbUJ7V3z/fqFyc= X-Received: by 2002:a17:902:a9c9:b0:161:5b73:5ac9 with SMTP id b9-20020a170902a9c900b001615b735ac9mr21345954plr.14.1657589333678; Mon, 11 Jul 2022 18:28:53 -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: Masahiko Sawada Date: Tue, 12 Jul 2022 10:28:17 +0900 Message-ID: Subject: Re: [BUG] Logical replication failure "ERROR: could not map filenode "base/13237/442428" to relation OID" with catalog modifying txns To: Amit Kapila 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 Tue, Jul 12, 2022 at 9:48 AM Masahiko Sawada wrote: > > On Fri, Jul 8, 2022 at 8:20 PM Masahiko Sawada wrote: > > > > On Fri, Jul 8, 2022 at 5:59 PM Amit Kapila wrote: > > > > > > On Fri, Jul 8, 2022 at 12:46 PM Masahiko Sawada wrote: > > > > > > > > On Fri, Jul 8, 2022 at 3:27 PM Amit Kapila wrote: > > > > > > > > > > > > > > 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. > > > > > > > > Since ReorderBufferGetcatalogChangesXacts() collects all ongoing > > > > catalog modifying transactions, the length of the array could be > > > > bigger than the one taken last time. We can start with the previous > > > > length but I think we cannot remove the need for repalloc. > > > > > > > > > > It is using the list "catchange_txns" to form xid array which > > > shouldn't change for the duration of > > > ReorderBufferGetCatalogChangesXacts(). Then the caller frees the xid > > > array after its use. Next time in > > > ReorderBufferGetCatalogChangesXacts(), the fresh allocation for xid > > > array happens, so not sure why repalloc would be required? > > > > Oops, I mistook catchange_txns for catchange->xcnt. You're right. > > Starting with the length of catchange_txns should be sufficient. > > > > I've attached an updated patch. > > While trying this idea, I noticed there is no API to get the length of > dlist, as we discussed offlist. Alternative idea was to use List > (T_XidList) but I'm not sure it's a great idea since deleting an xid > from the list is O(N), we need to implement list_delete_xid, and we > need to make sure allocating list node in the reorder buffer context. > So in the patch, I added a variable, catchange_ntxns, to keep track of > the length of the dlist. Please review it. > I'm doing benchmark tests and will share the results. Regards, -- Masahiko Sawada EDB: https://www.enterprisedb.com/