RE: apply worker misses closing partition leaves

From: "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>
Cc: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: RE: apply worker misses closing partition leaves
Date: 2026-08-24 10:33:46
Message-ID: TY4PR01MB17718CBF560E0E87AEC270D8594A02@TY4PR01MB17718.jpnprd01.prod.outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Monday, August 24, 2026 1:48 PM David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
> On Mon, 17 Aug 2026 at 23:53, Hayato Kuroda (Fujitsu)
> <kuroda(dot)hayato(at)fujitsu(dot)com> wrote:
> > While working on the parallel apply, I found that 013_partition.pl
> > raises WARNINGs like [1]. Per my research it happened after the
> > 39dcfda. The warning indicates the partition leaf opened by the worker is
> not expressly closed.
>
> > I'm not familiar with codes around triggers. But if we try to fix on
> > logical replication side, relations opened for triggers can be closed in
> finish_edata().
> > See attached.
>
> Thanks for the report and patch. I had a look and confirm that the warnings
> appear without the patch and are gone with the patch.
> However, I don't think it's a good idea to code the loop over
> estate->es_trig_target_relations the way you have it. Accessing
> EState's es_trig_target_relations field from worker.c to close open resources
> feels wrong.
>
> I modified your patch and added a new external function named
> ExecCloseTrigTargetRelations() and modified finish_edata() to call that
> instead. I also adjusted the 013_partition.pl test to grep the logs to ensure no
> more resource leaks.

The fix looks good to me. I just noticed one nit in the test:

+ ok(!$node->log_contains(qr/resource was not closed/),
+ 'unclosed resources on ' . $node->name);

I think the test message should be: "no unclosed resources on".

Best Regards,
Zhijie Hou

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Virender Singla 2026-08-24 10:38:10 Re: Allow pg_read_all_stats to read replication origin status
Previous Message Keyerror Smart 2026-08-24 10:13:28 [PATCH]Fix planner's strictness check for JsonExpr