pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Gierth <rhodiumtoad@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Avoid query-lifetime memory leaks in XMLTABLE (bug #15321)
Date: Mon, 13 Aug 2018 01:07:54 +0000
Message-ID: <E1fp1Ks-0004tx-5b@gemulon.postgresql.org> (raw)

Avoid query-lifetime memory leaks in XMLTABLE (bug #15321)

Multiple calls to XMLTABLE in a query (e.g. laterally applying it to a
table with an xml column, an important use-case) were leaking large
amounts of memory into the per-query context, blowing up memory usage.

Repair by reorganizing memory context usage in nodeTableFuncscan; use
the usual per-tuple context for row-by-row evaluations instead of
perValueCxt, and use the explicitly created context -- renamed from
perValueCxt to perTableCxt -- for arguments and state for each
individual table-generation operation.

Backpatch to PG10 where this code was introduced.

Original report by IRC user begriffs; analysis and patch by me.
Reviewed by Tom Lane and Pavel Stehule.

Discussion: https://postgr.es/m/153394403528.10284.7530399040974170549@wrigleys.postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/07172d5aff8f43cd6ce09f57a0b56a535d7eaf45

Modified Files
--------------
src/backend/executor/nodeTableFuncscan.c | 29 ++++++++++++++++++++++++-----
src/include/nodes/execnodes.h            |  2 +-
2 files changed, 25 insertions(+), 6 deletions(-)



view thread (3+ messages)  latest in thread

Message-ID: <E1fp1Ks-0004tx-5b@gemulon.postgresql.org>
Permalink:  ../E1fp1Ks-0004tx-5b@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1fp1Ks-0004tx-5b@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: rhodiumtoad@postgresql.org
  Subject: Re: pgsql: Avoid query-lifetime memory leaks in XMLTABLE (bug #15321)
  In-Reply-To: <E1fp1Ks-0004tx-5b@gemulon.postgresql.org>
  References: <E1fp1Ks-0004tx-5b@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox