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@postgresql.org
Subject: pgsql: Make pgstat tabstat lookup hash table less fragile.
Date: Mon, 15 May 2017 02:53:03 +0000
Message-ID: <E1dA687-0001D9-TW@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

Make pgstat tabstat lookup hash table less fragile.

Code review for commit 090010f2e.

Fix cases where an elog(ERROR) partway through a function would leave the
persistent data structures in a corrupt state.  pgstat_report_stat got this
wrong by invalidating PgStat_TableEntry structs before removing hashtable
entries pointing to them, and get_tabstat_entry got it wrong by ignoring
the possibility of palloc failure after it had already created a hashtable
entry.

Also, avoid leaking a memory context per transaction, which the previous
code did through misunderstanding hash_create's API.  We do not need to
create a context to hold the hash table; hash_create will do that.
(The leak wasn't that large, amounting to only a memory context header
per iteration, but it's still surprising that nobody noticed it yet.)

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5d00b764cd682f6071b35033f508a431d9d3f920

Modified Files
--------------
src/backend/postmaster/pgstat.c | 124 +++++++++++++++++++++-------------------
1 file changed, 64 insertions(+), 60 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


Message-ID: <E1dA687-0001D9-TW@gemulon.postgresql.org>
Permalink:  ../E1dA687-0001D9-TW@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1dA687-0001D9-TW@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: Make pgstat tabstat lookup hash table less fragile.
  In-Reply-To: <E1dA687-0001D9-TW@gemulon.postgresql.org>
  References: <E1dA687-0001D9-TW@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