pgsql: Code review for tqueue.c: fix memory leaks, speed it up, other f

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Code review for tqueue.c: fix memory leaks, speed it up, other f
Date: 2016-07-31 20:05:32
Message-ID: E1bTwzM-0006dx-BQ@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Code review for tqueue.c: fix memory leaks, speed it up, other fixes.

When doing record typmod remapping, tqueue.c did fresh catalog lookups
for each tuple it processed, which was pretty horrible performance-wise
(it seemed to about halve the already none-too-quick speed of bulk reads
in parallel mode). Worse, it insisted on putting bits of that data into
TopMemoryContext, from where it never freed them, causing a
session-lifespan memory leak. (I suppose this was coded with the idea
that the sender process would quit after finishing the query ---
but the receiver uses the same code.)

Restructure to avoid repetitive catalog lookups and to keep that data
in a query-lifespan context, in or below the context where the
TQueueDestReceiver or TupleQueueReader itself lives.

Fix some other bugs such as continuing to use a tupledesc after
releasing our refcount on it. Clean up cavalier datatype choices
(typmods are int32, please, not int, and certainly not Oid). Improve
comments and error message wording.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/a9ed875fdc2c44b5793a07727274786b417fc924

Modified Files
--------------
src/backend/executor/tqueue.c | 1142 +++++++++++++++++++++++++----------------
1 file changed, 695 insertions(+), 447 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2016-07-31 22:33:21 pgsql: Doc: remove claim that hash index creation depends on effective_
Previous Message Stephen Frost 2016-07-31 14:57:20 pgsql: Correctly handle owned sequences with extensions