On Fri, Nov 27, 2026 at 1:31 PM Hayato Kuroda (Fujitsu) <[email protected]> wrote: > > Hi, > > > 1. Apply worker reports the partitioned table instead of the leaf > > partition in some errors > > I found that error context callback reports the remote relation's name as > "target relation", so it's consistent with it. When I ran the test after > patching, > I got the below output: > > ``` > ERROR: logical replication target relation "public.tab5_1" has neither > REPLICA IDENTITY index nor PRIMARY KEY and published relation does not have > REPLICA IDENTITY FULL > CONTEXT: processing remote data for replication origin "pg_16420" during > message type "UPDATE" for replication target relation "public.tab5" in > transaction 740, finished at 0/01808168 > ``` > > I feel Wwe should fix all or retain them. >
I don't think the two lines need to name the same relation, because they report different things. The CONTEXT describes the change as it arrived: it is set from the map entry of the relation named in the replication message, before tuple routing picks a partition. The ERROR reports the relation that failed the check, which for a routed change is the leaf partition. Both are subscriber relations, so "target" fits both. This is also what the apply worker already does elsewhere for routed changes. Conflict reports name the leaf partition while the CONTEXT names the replicated table; for example, 013_partition.pl checks for 'conflict detected on relation "public.tab1_2_2"', and tab1_2_2 exists only on the subscriber. CheckSubscriptionTargetRel() also reports the leaf partition. With 0001, check_relation_updatable() behaves the same way. Making the CONTEXT name the leaf as well would mean switching the error callback's entry during routing. That is only possible for UPDATE and DELETE, since a routed INSERT has no partition map entry, and the replicated relation would then not appear in the output at all. Keeping both on the root means keeping a message that can be false, as in the example in my first mail. > > 2. Missing RelationClose() in check_and_init_gencol() > > I have no strong opinion to fix it, but pgoutput_ensure_entry_cxt() should > also > be done if we fix. Good catch, thanks. pgoutput_ensure_entry_cxt() has had the same leak since PG 15. The attached v2-0002 adds RelationClose() there too. I checked the other RelationIdGetRelation() callers in pgoutput.c, and they all close the relation. v2-0001 is unchanged. Regards, Ajin Cherian Fujitsu Australia
v2-0001-Report-the-leaf-partition-in-apply-worker-errors.patch
Description: Binary data
v2-0002-Close-relations-opened-in-pgoutput-helper-functio.patch
Description: Binary data
