Re: apply worker misses closing partition leaves

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: "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 05:48:04
Message-ID: CAApHDvqkySv8ADiuY7mqbAzpNv2jzPRQOtjjnSc2tGgRGG8wug@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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. I did wonder if something like
that should appear somewhere more generic so it applies to more tests,
but I didn't study the TAP test harness enough to understand where
that might go.

The leak message did change in b8bff07da, so I've attached two
patches, v16 for 15-16 and v20 for 17-master.

David

Attachment Content-Type Size
v16-0001-Close-relations-opened-specifically-for-AFTER-tr.patch application/octet-stream 4.6 KB
v20-0001-Close-relations-opened-specifically-for-AFTER-tr.patch application/octet-stream 4.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrey Borodin 2026-08-24 06:05:04 Re: Checkpointer write combining
Previous Message shveta malik 2026-08-24 05:40:08 Re: Support EXCEPT for TABLES IN SCHEMA publications