pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Prevent query-lifespan memory leakage of SP-GiST traversal value
Date: Tue, 20 Mar 2018 03:59:41 +0000
Message-ID: <E1ey8R3-0008Se-9p@gemulon.postgresql.org> (raw)

Prevent query-lifespan memory leakage of SP-GiST traversal values.

The original coding of the SP-GiST scan traversalValue feature (commit
ccd6eb49a) arranged for traversal values to be stored in the query's main
executor context.  That's fine if there's only one index scan per query,
but if there are many, we have a memory leak as successive scans create
new traversal values.  Fix it by creating a separate memory context for
traversal values, which we can reset during spgrescan().  Back-patch
to 9.6 where this code was introduced.

In principle, adding the traversalCxt field to SpGistScanOpaqueData
creates an ABI break in the back branches.  But I (tgl) have little
sympathy for extensions including spgist_private.h, so I'm not very
worried about that.  Alternatively we could stick the new field at the
end of the struct in back branches, but that has its own downsides.

Anton Dignös, reviewed by Alexander Kuzmenkov

Discussion: https://postgr.es/m/CALNdv1jb6y2Te-m8xHLxLX12RsBmZJ1f4hESX7J0HjgyOhA9eA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/467963c3e9c5ba9a953959f8aebcdd7206188a18

Modified Files
--------------
src/backend/access/spgist/spgscan.c | 9 ++++++++-
src/include/access/spgist_private.h | 1 +
2 files changed, 9 insertions(+), 1 deletion(-)



view thread (3+ messages)  latest in thread

Message-ID: <E1ey8R3-0008Se-9p@gemulon.postgresql.org>
Permalink:  ../E1ey8R3-0008Se-9p@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1ey8R3-0008Se-9p@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: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Prevent query-lifespan memory leakage of SP-GiST traversal value
  In-Reply-To: <E1ey8R3-0008Se-9p@gemulon.postgresql.org>
  References: <E1ey8R3-0008Se-9p@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