Re: BUG #15700: PG 10 vs. 11: Large increase in memory usage when selecting BYTEA data (maybe memory leak)

From: Andres Freund <andres(at)anarazel(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, Matthias Otterbach <mo(at)otterbach(dot)eu>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #15700: PG 10 vs. 11: Large increase in memory usage when selecting BYTEA data (maybe memory leak)
Date: 2019-03-18 22:24:06
Message-ID: 20190318222406.nlc6372xfou4kr5o@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

On 2019-03-18 18:03:40 -0400, Tom Lane wrote:
> Andres Freund <andres(at)anarazel(dot)de> writes:
> > We're also assuming that we don't leak into MessageContext over such
> > cycles, which seems wrong. At the very least things like
> > errdetail_params() are happy to leak into MessageContext.
>
> This leak isn't in MessageContext; if it were, there likely wouldn't
> have been a noticeable problem.

I know that this leak wasn't into MessageContext - I was (wrongly)
thinking that there also might be an issue related to MessageContext
too, but I was wrong on that.

> It's leaking in the executor's
> context over repeat ExecutorRun cycles in the same execution state.

What I don't quite get is why we're doing

if (sendTuples)
dest->rStartup(dest, operation, queryDesc->tupDesc);

inside the per-query context, given that the lifetime of the started
dest receiver can be, like in this example, be considerably shorter than
the query execution. I guess given the current interface we can't
really do much better, as we'd also not want to leak into the calling
context, and allocating yet another memory context wouldn't be cheap :(

Greetings,

Andres Freund

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2019-03-18 22:37:28 Re: pg_upgrade
Previous Message Tomasz Szypowski 2019-03-18 22:05:54 Re: pg_upgrade