Re: BUG #16112: large, unexpected memory consumption

Поиск
Список
Период
Сортировка
От Tomas Vondra
Тема Re: BUG #16112: large, unexpected memory consumption
Дата
Msg-id 20191113145004.opxx4vuajyoadbcq@development
обсуждение исходный текст
Ответ на BUG #16112: large, unexpected memory consumption  (PG Bug reporting form <noreply@postgresql.org>)
Ответы Re: BUG #16112: large, unexpected memory consumption  (Andres Freund <andres@anarazel.de>)
Re: BUG #16112: large, unexpected memory consumption  (Jeff Janes <jeff.janes@gmail.com>)
Список pgsql-bugs
On Wed, Nov 13, 2019 at 12:22:07PM +0000, PG Bug reporting form wrote:
>The following bug has been logged on the website:
>
>Bug reference:      16112
>Logged by:          Ben Cornett
>Email address:      ben@lantern.is
>PostgreSQL version: 12.0
>Operating system:   linux 2.6.32
>Description:
>
>Creation of table t1 in the query below causes the server process to consume
>close to 1GB of memory.  The amount of memory consumed is proportional to
>the value passed to generate_series in the first query.
>
>CREATE temp TABLE t0 AS
>SELECT
>        i,
>        ARRAY[1,2,3] a
>FROM GENERATE_SERIES(1, 12000000) i
>;
>
>CREATE TEMP TABLE t1 AS
>SELECT
>        i,
>        x
>FROM t0, UNNEST(a) x;
>
>I observed the same behavior in other test queries that included implicit
>lateral joins.
>

Yeah, I can reproduce this pretty easily. It seems like a memory leak in
ExecMakeTableFunctionResult. a9c35cf85ca reworked FunctionCallInfo to be
variable-length, but it gets allocated in ExecutorState context directly
and so until the end of the query.

The attached trivial patch fixes that by adding a pfree() at the end of
the function. I wonder if we have the same issue elsewhere ...


regards

-- 
Tomas Vondra                  http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Вложения

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Jeff Janes
Дата:
Сообщение: Re: REINDEX CONCURRENTLY unexpectedly fails
Следующее
От: Tom Lane
Дата:
Сообщение: Re: 回复: BUG #16101: tables in the DB is not available after pg_restore