pgsql: Fix query-lifespan memory leakage in repeatedly executed hashjo - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Fix query-lifespan memory leakage in repeatedly executed hashjo
Date
Msg-id E1ewvaG-000703-Dn@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix query-lifespan memory leakage in repeatedly executed hash joins.

ExecHashTableCreate allocated some memory that wasn't freed by
ExecHashTableDestroy, specifically the per-hash-key function information.
That's not a huge amount of data, but if one runs a query that repeats
a hash join enough times, it builds up.  Fix by arranging for the data
in question to be kept in the hashtable's hashCxt instead of leaving it
"loose" in the query-lifespan executor context.  (This ensures that we'll
also clean up anything that the hash functions allocate in fn_mcxt.)

Per report from Amit Khandekar.  It's been like this forever, so back-patch
to all supported branches.

Discussion: https://postgr.es/m/CAJ3gD9cFofAWGvcxLOxDHC=B0hjtW8yGmUsF2hdGh97CM38=7g@mail.gmail.com

Branch
------
REL9_3_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/574386ddca69b4126e77f993d3d770c85f99d209

Modified Files
--------------
src/backend/executor/nodeHash.c | 43 +++++++++++++++++++++--------------------
1 file changed, 22 insertions(+), 21 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Doc: explicitly point out that enum values can't be dropped.
Next
From: Andres Freund
Date:
Subject: pgsql: Add 'unit' parameter to ExplainProperty{Integer,Float}.