pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix memory leak coming from simple lists built in reindexdb
Date: Tue, 30 Jul 2019 01:56:48 +0000
Message-ID: <E1hsHNg-0006Ud-Sb@gemulon.postgresql.org> (raw)

Fix memory leak coming from simple lists built in reindexdb

When building a list of relations for a parallel processing of a schema
or a database (or just a single-entry list for the non-parallel case
with the database name), the list is allocated and built on-the-fly for
each database processed, leaking after one database-level reindex is
done.  This accumulates leaks when processing all databases, and could
become a visible issue with thousands of relations.

This is fixed by introducing a new routine in simple_list.c to free all
the elements in a simple list made of strings or OIDs.  The header of
the list may be using a variable declaration or an allocated pointer,
so we don't have a routine to free this part to keep the interface
simple.

Per report from coverity for an issue introduced by 5ab892c, and
valgrind complains about the leak as well.  The idea to introduce a new
routine in simple_list.c is from Tom Lane.

Author: Michael Paquier
Reviewed-by: Tom Lane

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/04cf0bfc90dfae89a794d2bdd88fe3b8e313798e

Modified Files
--------------
src/bin/scripts/reindexdb.c        |  6 ++++++
src/fe_utils/simple_list.c         | 38 ++++++++++++++++++++++++++++++++++++++
src/include/fe_utils/simple_list.h |  2 ++
3 files changed, 46 insertions(+)



Message-ID: <E1hsHNg-0006Ud-Sb@gemulon.postgresql.org>
Permalink:  ../E1hsHNg-0006Ud-Sb@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1hsHNg-0006Ud-Sb@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: michael@paquier.xyz
  Subject: Re: pgsql: Fix memory leak coming from simple lists built in reindexdb
  In-Reply-To: <E1hsHNg-0006Ud-Sb@gemulon.postgresql.org>
  References: <E1hsHNg-0006Ud-Sb@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