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 1oFDNs-0008Sa-Rw for pgsql-hackers@arkaria.postgresql.org; Sat, 23 Jul 2022 11:33:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oFDMs-0005Jz-Uu for pgsql-hackers@arkaria.postgresql.org; Sat, 23 Jul 2022 11:32:22 +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 1oFDMs-0005Jm-IH for pgsql-hackers@lists.postgresql.org; Sat, 23 Jul 2022 11:32:22 +0000 Received: from mail-yw1-x112b.google.com ([2607:f8b0:4864:20::112b]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oFDMn-0003UQ-8V for pgsql-hackers@lists.postgresql.org; Sat, 23 Jul 2022 11:32:21 +0000 Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-31e67c46ba2so69975297b3.2 for ; Sat, 23 Jul 2022 04:32:16 -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=ylyYeL7FmoOnQBCGUykBNKHz+dnGmjA4c/ovg+ytF2E=; b=bzBF5FNf2xoY6Bq+13qEICm8W/0iVHGzR2j3q2+T3zhTJ8pY/tbLHIJr3o0A6J4QPd sm8JeRd2bTxkeHBPPXbk8rJJQVuc9JJcFWf93Mi7eoJ2DVzCWzWo/E/whsDU9TbLIgFu VUzv4D1RZX70S9D9VWn8bu8wakP4TyFO5b4IXxV42ZNUclKWgY9bQVcaQW6Vgjyg6AaA Kh0wMH3dklM9aoUmTko/WMT8XRuYjy5lwP4w8BuBFX+bTICgM/54pqexo3LrKekivHzn EaLdbC6H1x7/eyo+cphOA6IjIhYQIBBubENqFUNb+kcCM1yHt/NDQOsXuEkm1Y7Tbkhf OFQg== 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=ylyYeL7FmoOnQBCGUykBNKHz+dnGmjA4c/ovg+ytF2E=; b=lPPUIpWi4MUhKAoBp1s7kOob3GJy9fyGyXh/ULzBKnl9uO9ysZ0vQZAhGOG/nyh9PC 2TkwB55uP9pC7gHJ1ucf2+zaETbkswlPRZJjGkD8TdLgO1jsuWxcV7Da1eGb841nfYXz jLuDiVUz35T+qjwbD+3g+faXPBsJ1ra6+NCcjW/7qKVWvwpxbEQV8gcKJ7g21GIT4f/Q D5nY8Sb6f9ktWMTFzE8WU3Bw7ZcUtLyQ2VuoaZXCjNIKWKZEfy9oefZ9cowuJ387LcGk 1HOmehBHHBJZRHeo8s43nK5Sp/+53cc1RrOtrjZt3hkQA/2I0U9cwG3ud0EHUgU2iBN6 x3Tw== X-Gm-Message-State: AJIora9v4W2CjZfoNk5WxxDA6FW1BfVGBLNn5KSYtrbWHknJ6yQyGEv6 3j/d5eizZ0UdQWboE2fCIb3mSXtL4AalL/8xbVY= X-Google-Smtp-Source: AGRyM1vKj7ZqEKjmk2o9iYFlnFizCfnqq0pT7mOaFz7kSBzTmCs1pzLlBO6uMHz6ac78LZI3Pd+ziCfJY7yKwH18i60= X-Received: by 2002:a0d:d58b:0:b0:31e:a641:849e with SMTP id x133-20020a0dd58b000000b0031ea641849emr3283699ywd.223.1658575934306; Sat, 23 Jul 2022 04:32:14 -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: Sat, 23 Jul 2022 17:02:02 +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: "shiy.fnst@fujitsu.com" , Kyotaro Horiguchi , "Drouvot, Bertrand" , PostgreSQL Hackers , "Oh, Mike" Content-Type: multipart/mixed; boundary="00000000000067492805e4774d4e" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000067492805e4774d4e Content-Type: text/plain; charset="UTF-8" On Fri, Jul 22, 2022 at 11:48 AM Masahiko Sawada wrote: > > On Wed, Jul 20, 2022 at 5:50 PM Amit Kapila wrote: > > > > On Wed, Jul 20, 2022 at 1:28 PM Masahiko Sawada wrote: > > > > > > > This is required if we don't want to introduce a new set of functions > > as you proposed above. I am not sure which one is better w.r.t back > > patching effort later but it seems to me using flag stuff would make > > future back patches easier if we make any changes in > > SnapBuildCommitTxn. > > Understood. > > I've implemented this idea as well for discussion. Both patches have > the common change to remember the initial running transactions and to > purge them when decoding xl_running_xacts records. The difference is > how to mark the transactions as needing to be added to the snapshot. > > In v7-0001-Fix-catalog-lookup-with-the-wrong-snapshot-during.patch, > when the transaction is in the initial running xact list and its > commit record has XINFO_HAS_INVAL flag, we mark both the top > transaction and its all subtransactions as containing catalog changes > (which also means to create ReorderBufferTXN entries for them). These > transactions are added to the snapshot in SnapBuildCommitTxn() since > ReorderBufferXidHasCatalogChanges () for them returns true. > > In poc_mark_top_txn_has_inval.patch, when the transaction is in the > initial running xacts list and its commit record has XINFO_HAS_INVALS > flag, we set a new flag, say RBTXN_COMMIT_HAS_INVALS, only to the top > transaction. > It seems that the patch has missed the part to check if the xid is in the initial running xacts list? > In SnapBuildCommitTxn(), we add all subtransactions to > the snapshot without checking ReorderBufferXidHasCatalogChanges() for > subtransactions if its top transaction has the RBTXN_COMMIT_HAS_INVALS > flag. > > A difference between the two ideas is the scope of changes: the former > changes only snapbuild.c but the latter changes both snapbuild.c and > reorderbuffer.c. Moreover, while the former uses the existing flag, > the latter adds a new flag to the reorder buffer for dealing with only > this case. I think the former idea is simpler in terms of that. But, > an advantage of the latter idea is that the latter idea can save to > create ReorderBufferTXN entries for subtransactions. > > Overall I prefer the former for now but I'd like to hear what others think. > I agree that the latter idea can have better performance in extremely special scenarios but introducing a new flag for the same sounds a bit ugly to me. So, I would also prefer to go with the former idea, however, I would also like to hear what Horiguchi-San and others have to say. Few comments on v7-0001-Fix-catalog-lookup-with-the-wrong-snapshot-during: 1. +void +SnapBuildInitialXactSetCatalogChanges(SnapBuild *builder, TransactionId xid, + int subxcnt, TransactionId *subxacts, + XLogRecPtr lsn) +{ I think it is better to name this function as SnapBuildXIDSetCatalogChanges as we use this to mark a particular transaction as having catalog changes. 2. Changed/added a few comments in the attached. -- With Regards, Amit Kapila. --00000000000067492805e4774d4e Content-Type: application/octet-stream; name="v7-0001-diff-amit.patch" Content-Disposition: attachment; filename="v7-0001-diff-amit.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_l5xt9zhv0 ZGlmZiAtLWdpdCBhL3NyYy9iYWNrZW5kL3JlcGxpY2F0aW9uL2xvZ2ljYWwvZGVjb2RlLmMgYi9z cmMvYmFja2VuZC9yZXBsaWNhdGlvbi9sb2dpY2FsL2RlY29kZS5jCmluZGV4IDc4YjljYTQ4Yzcu LjA1YjljNDFlODggMTAwNjQ0Ci0tLSBhL3NyYy9iYWNrZW5kL3JlcGxpY2F0aW9uL2xvZ2ljYWwv ZGVjb2RlLmMKKysrIGIvc3JjL2JhY2tlbmQvcmVwbGljYXRpb24vbG9naWNhbC9kZWNvZGUuYwpA QCAtNjI5LDExICs2MjksMTMgQEAgRGVjb2RlQ29tbWl0KExvZ2ljYWxEZWNvZGluZ0NvbnRleHQg KmN0eCwgWExvZ1JlY29yZEJ1ZmZlciAqYnVmLAogCiAJLyoKIAkgKiBJZiB0aGUgQ09NTUlUIHJl Y29yZCBoYXMgaW52YWxpZGF0aW9uIG1lc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