| From: | Ajin Cherian <itsajin(at)gmail(dot)com> |
|---|---|
| To: | "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Wrong relation in apply worker "not updatable" errors PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>for partitions; relcache leak in check_and_init_gencol() |
| Date: | 2026-12-01 07:15:36 |
| Message-ID: | CAFPTHDYvesxg9LVkg4Nq8k718_pne7dRMJpSdzy_nAFF69Q6qg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Fri, Nov 27, 2026 at 1:31 PM Hayato Kuroda (Fujitsu)
<kuroda(dot)hayato(at)fujitsu(dot)com> 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
| Attachment | Content-Type | Size |
|---|---|---|
| v2-0001-Report-the-leaf-partition-in-apply-worker-errors.patch | application/octet-stream | 5.0 KB |
| v2-0002-Close-relations-opened-in-pgoutput-helper-functio.patch | application/octet-stream | 1.7 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2026-12-01 07:19:36 | Re: pgstat: Flush some statistics within running transactions, take 2 |
| Previous Message | Nisha Moond | 2026-12-01 07:12:06 | Re: Add a hook for handling logical decoding messages on subscribers. |