]> granicus.if.org Git - postgresql/commit
Fix query-lifespan memory leakage in repeatedly executed hash joins.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 16 Mar 2018 20:03:45 +0000 (16:03 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 16 Mar 2018 20:03:45 +0000 (16:03 -0400)
commitc17a58967d97461a088ca2f19da4c46cf35e4194
tree09a51c56bf801e7c08b6d461356a9cb9ea9c5fa7
parentf4512fa5b3af82ce07ebee78f80b93aa8d654e3a
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
src/backend/executor/nodeHash.c