Re: memory leak in auto_explain

From: japin <japinli(at)hotmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: memory leak in auto_explain
Date: 2021-02-03 04:30:56
Message-ID: MEYP282MB1669B5A06AD6E45A7220B1F3B6B49@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On Wed, 03 Feb 2021 at 02:13, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> japin <japinli(at)hotmail(dot)com> writes:
>> Here's my analysis:
>> 1) In the explain_ExecutorEnd(), it will create a ExplainState on SQL function
>> memory context, which is a long-lived, cause the memory grow up.
>
> Yeah, agreed. I think people looking at this have assumed that the
> ExecutorEnd hook would automatically be running in the executor's
> per-query context, but that's not so; we haven't yet entered
> standard_ExecutorEnd where the context switch is. The caller's
> context is likely to be much longer-lived than the executor's.
>
> I think we should put the switch one level further out than you have
> it here, just to be sure that InstrEndLoop is covered too (that doesn't
> allocate memory, but auto_explain shouldn't assume that). Otherwise
> seems like a good fix.
>

Thanks for your review and clarification.

--
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip Kumar 2021-02-03 04:55:39 Re: [HACKERS] Custom compression methods
Previous Message Peter Smith 2021-02-03 03:51:30 Re: Single transaction in the tablesync worker?