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 1o8uSc-0005if-Mn for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Jul 2022 02:08:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o8uSb-0001dx-78 for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Jul 2022 02:08:13 +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 1o8uSa-0001di-UP for pgsql-hackers@lists.postgresql.org; Wed, 06 Jul 2022 02:08:12 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1o8uSY-0001KS-EN for pgsql-hackers@lists.postgresql.org; Wed, 06 Jul 2022 02:08:12 +0000 Received: by mail-pl1-x633.google.com with SMTP id y18so4461335plb.2 for ; Tue, 05 Jul 2022 19:08:10 -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=LqUJT3NRU2CItIxoETb/R99sCJJMt8qcyru1G7t2EE8=; b=UO68oc5N8Z4SDVp/Tk5vrAAsGjlOUlclKn7j6MaB/iXWbluU9EF5FEtFBiK7auX9/v +59ShbPB49rnh63qjO8u5i2LTM1qAplws/q9FkZEnpdoLFjlFvyvdAXPoleuhJrkMyH0 Vq3YJ6dfFybxf1i0U3wp6G8p1Dgm0BwjJ2OVls3Wz2t56d6p3ov+IB5ih3h6B08iCKon 4GNQ0XiQZN5UZyxoUpLJ3HqucfKRVlrKef1rT5Xp2hYmh2XLEePKtpRp2Y4abeW853MP ug+F+RAE7EIrLUfGMDIFuDLx8ZskWn+1rgy2FZSEPxuTPPk7gJXzJphwivJGN/E1i7Wd XryA== 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=LqUJT3NRU2CItIxoETb/R99sCJJMt8qcyru1G7t2EE8=; b=Z+l5Z8ktXtLtsH7Ry/q/y5f5POOmSdSgUrP0Eibc6XvnQbZlTNvQtDyJaZrAXWJX2q xk2iaprm0U2ChD8KJA1PbDvAvJ+poLhMmL6YI+K4bFnaJtdMVTWtQmf3h7AJyRMKt86f IvYgV2zCRNd+J58VZtXsiZ/VAn2loIAIVNfPuzg2oJyi/y7V/RsQ1FzopWJzHYsCJjLf 2ziSQIz7gQqdSc88iJ0ilSoB9STu2vEPPCQUKNe3h1LlCIontFEofEZXRXl3OJvorWgL d0sSLUpi25m0xCk0+RiXyd2ONai+5Xmf9/vDpbhz4F+PAEgyLpgoP8n11eQ4/itLWEXr YEaQ== X-Gm-Message-State: AJIora/oiarozmwulUyIYzEPgMTyFk6019l7zjZffwxpYjqB/fDLOvyC NcABRgIxdkbGZs6Rics2xYO3sUBvMhc2H2QwMMU= X-Google-Smtp-Source: AGRyM1sZIUJm3fAkGwFSowiqlkIlJh2ScArHSjD1lgCniLoJo1ovb2dbrvDdnahaKMYR/p1MOOFXxOt/HnkHF+wXA4M= X-Received: by 2002:a17:903:2405:b0:16a:8010:1e16 with SMTP id e5-20020a170903240500b0016a80101e16mr45430255plo.87.1657073288628; Tue, 05 Jul 2022 19:08:08 -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: Wed, 6 Jul 2022 11:07:32 +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 Mon, Jul 4, 2022 at 9:42 PM Amit Kapila wrote: > > On Mon, May 30, 2022 at 11:13 AM Masahiko Sawada wrote: > > > > I've attached three POC patches: > > > > I think it will be a good idea if you can add a short commit message > at least to say which patch is proposed for HEAD and which one is for > back branches. Also, it would be good if you can add some description > of the fix in the commit message. Let's remove poc* from the patch > name. Updated. > > Review poc_add_running_catchanges_xacts_to_serialized_snapshot > ===================================================== > 1. > + /* > + * Array of transactions that were running when the snapshot serialization > + * and changed system catalogs, > > The part of the sentence after serialization is not very clear. Updated. > > 2. > - if (ReorderBufferXidHasCatalogChanges(builder->reorder, subxid)) > + if (ReorderBufferXidHasCatalogChanges(builder->reorder, subxid) || > + bsearch(&xid, builder->catchanges.xip, builder->catchanges.xcnt, > + sizeof(TransactionId), xidComparator) != NULL) > > Why are you using xid instead of subxid in bsearch call? Can we add a > comment to say why it is okay to use xid if there is a valid reason? > But note, we are using subxid to add to the committed xact array so > not sure if this is a good idea but I might be missing something. You're right, subxid should be used here. > > Suggestions for improvement in comments: > - /* > - * Update the transactions that are running and changes > catalogs that are > - * not committed. > - */ > + /* Update the catalog modifying transactions that are yet not > committed. */ > if (builder->catchanges.xip) > pfree(builder->catchanges.xip); > builder->catchanges.xip = > ReorderBufferGetCatalogChangesXacts(builder->reorder, > @@ -1647,7 +1644,7 @@ SnapBuildSerialize(SnapBuild *builder, XLogRecPtr lsn) > COMP_CRC32C(ondisk->checksum, ondisk_c, sz); > ondisk_c += sz; > > - /* copy catalog-changes xacts */ > + /* copy catalog modifying xacts */ > sz = sizeof(TransactionId) * builder->catchanges.xcnt; > memcpy(ondisk_c, builder->catchanges.xip, sz); > COMP_CRC32C(ondisk->checksum, ondisk_c, sz); Updated. I'll post a new version patch in the next email with replying to other comments. Regards, -- Masahiko Sawada EDB: https://www.enterprisedb.com/