pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix memory leakage in plpgsql DO blocks that use cast expression 5+ messages / 1 participants [nested] [flat]
* pgsql: Fix memory leakage in plpgsql DO blocks that use cast expression @ 2023-04-24 18:20 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2023-04-24 18:20 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix memory leakage in plpgsql DO blocks that use cast expressions. Commit 04fe805a1 modified plpgsql so that datatype casts make use of expressions cached by plancache.c, in place of older code where these expression trees were managed by plpgsql itself. However, I (tgl) forgot that we use a separate, shorter-lived cast info hashtable in DO blocks. The new mechanism thus resulted in session-lifespan leakage of the plancache data once a DO block containing one or more casts terminated. To fix, split the cast hash table into two parts, one that tracks only the plancache's CachedExpressions and one that tracks the expression state trees generated from them. DO blocks need their own expression state trees and hence their own version of the second hash table, but there's no reason they can't share the CachedExpressions with regular plpgsql functions. Per report from Ajit Awekar. Back-patch to v12 where the issue was introduced. Ajit Awekar and Tom Lane Discussion: https://postgr.es/m/CAHv6PyrNaqdvyWUspzd3txYQguFTBSnhx+m6tS06TnM+KWc_LQ@mail.gmail.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/441ee1677e6b580794c81943a937cd84363672f3 Modified Files -------------- src/pl/plpgsql/src/pl_exec.c | 94 ++++++++++++++++++++++++++++++-------------- src/pl/plpgsql/src/plpgsql.h | 1 - 2 files changed, 65 insertions(+), 30 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Fix memory leakage in plpgsql DO blocks that use cast expression @ 2023-04-24 18:20 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2023-04-24 18:20 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix memory leakage in plpgsql DO blocks that use cast expressions. Commit 04fe805a1 modified plpgsql so that datatype casts make use of expressions cached by plancache.c, in place of older code where these expression trees were managed by plpgsql itself. However, I (tgl) forgot that we use a separate, shorter-lived cast info hashtable in DO blocks. The new mechanism thus resulted in session-lifespan leakage of the plancache data once a DO block containing one or more casts terminated. To fix, split the cast hash table into two parts, one that tracks only the plancache's CachedExpressions and one that tracks the expression state trees generated from them. DO blocks need their own expression state trees and hence their own version of the second hash table, but there's no reason they can't share the CachedExpressions with regular plpgsql functions. Per report from Ajit Awekar. Back-patch to v12 where the issue was introduced. Ajit Awekar and Tom Lane Discussion: https://postgr.es/m/CAHv6PyrNaqdvyWUspzd3txYQguFTBSnhx+m6tS06TnM+KWc_LQ@mail.gmail.com Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/c1598d85fe465e650e6af126610c8e33c450f939 Modified Files -------------- src/pl/plpgsql/src/pl_exec.c | 94 ++++++++++++++++++++++++++++++-------------- src/pl/plpgsql/src/plpgsql.h | 2 +- 2 files changed, 66 insertions(+), 30 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Fix memory leakage in plpgsql DO blocks that use cast expression @ 2023-04-24 18:20 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2023-04-24 18:20 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix memory leakage in plpgsql DO blocks that use cast expressions. Commit 04fe805a1 modified plpgsql so that datatype casts make use of expressions cached by plancache.c, in place of older code where these expression trees were managed by plpgsql itself. However, I (tgl) forgot that we use a separate, shorter-lived cast info hashtable in DO blocks. The new mechanism thus resulted in session-lifespan leakage of the plancache data once a DO block containing one or more casts terminated. To fix, split the cast hash table into two parts, one that tracks only the plancache's CachedExpressions and one that tracks the expression state trees generated from them. DO blocks need their own expression state trees and hence their own version of the second hash table, but there's no reason they can't share the CachedExpressions with regular plpgsql functions. Per report from Ajit Awekar. Back-patch to v12 where the issue was introduced. Ajit Awekar and Tom Lane Discussion: https://postgr.es/m/CAHv6PyrNaqdvyWUspzd3txYQguFTBSnhx+m6tS06TnM+KWc_LQ@mail.gmail.com Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/2ba890ce7ed2b1362174f5a6686b94dcd9628949 Modified Files -------------- src/pl/plpgsql/src/pl_exec.c | 94 ++++++++++++++++++++++++++++++-------------- src/pl/plpgsql/src/plpgsql.h | 2 +- 2 files changed, 66 insertions(+), 30 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Fix memory leakage in plpgsql DO blocks that use cast expression @ 2023-04-24 18:20 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2023-04-24 18:20 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix memory leakage in plpgsql DO blocks that use cast expressions. Commit 04fe805a1 modified plpgsql so that datatype casts make use of expressions cached by plancache.c, in place of older code where these expression trees were managed by plpgsql itself. However, I (tgl) forgot that we use a separate, shorter-lived cast info hashtable in DO blocks. The new mechanism thus resulted in session-lifespan leakage of the plancache data once a DO block containing one or more casts terminated. To fix, split the cast hash table into two parts, one that tracks only the plancache's CachedExpressions and one that tracks the expression state trees generated from them. DO blocks need their own expression state trees and hence their own version of the second hash table, but there's no reason they can't share the CachedExpressions with regular plpgsql functions. Per report from Ajit Awekar. Back-patch to v12 where the issue was introduced. Ajit Awekar and Tom Lane Discussion: https://postgr.es/m/CAHv6PyrNaqdvyWUspzd3txYQguFTBSnhx+m6tS06TnM+KWc_LQ@mail.gmail.com Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/bfa691087eacc6e0fbf1a0d8ee392c3d2ff3cb34 Modified Files -------------- src/pl/plpgsql/src/pl_exec.c | 95 ++++++++++++++++++++++++++++++-------------- src/pl/plpgsql/src/plpgsql.h | 2 +- 2 files changed, 67 insertions(+), 30 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Fix memory leakage in plpgsql DO blocks that use cast expression @ 2023-04-24 18:20 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2023-04-24 18:20 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix memory leakage in plpgsql DO blocks that use cast expressions. Commit 04fe805a1 modified plpgsql so that datatype casts make use of expressions cached by plancache.c, in place of older code where these expression trees were managed by plpgsql itself. However, I (tgl) forgot that we use a separate, shorter-lived cast info hashtable in DO blocks. The new mechanism thus resulted in session-lifespan leakage of the plancache data once a DO block containing one or more casts terminated. To fix, split the cast hash table into two parts, one that tracks only the plancache's CachedExpressions and one that tracks the expression state trees generated from them. DO blocks need their own expression state trees and hence their own version of the second hash table, but there's no reason they can't share the CachedExpressions with regular plpgsql functions. Per report from Ajit Awekar. Back-patch to v12 where the issue was introduced. Ajit Awekar and Tom Lane Discussion: https://postgr.es/m/CAHv6PyrNaqdvyWUspzd3txYQguFTBSnhx+m6tS06TnM+KWc_LQ@mail.gmail.com Branch ------ REL_12_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/ee71cad9a7c05e705531938f3a92b8bd8ad97ce2 Modified Files -------------- src/pl/plpgsql/src/pl_exec.c | 95 ++++++++++++++++++++++++++++++-------------- src/pl/plpgsql/src/plpgsql.h | 2 +- 2 files changed, 67 insertions(+), 30 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2023-04-24 18:20 UTC | newest] Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2023-04-24 18:20 pgsql: Fix memory leakage in plpgsql DO blocks that use cast expression Tom Lane <tgl@sss.pgh.pa.us> 2023-04-24 18:20 pgsql: Fix memory leakage in plpgsql DO blocks that use cast expression Tom Lane <tgl@sss.pgh.pa.us> 2023-04-24 18:20 pgsql: Fix memory leakage in plpgsql DO blocks that use cast expression Tom Lane <tgl@sss.pgh.pa.us> 2023-04-24 18:20 pgsql: Fix memory leakage in plpgsql DO blocks that use cast expression Tom Lane <tgl@sss.pgh.pa.us> 2023-04-24 18:20 pgsql: Fix memory leakage in plpgsql DO blocks that use cast expression Tom Lane <tgl@sss.pgh.pa.us>
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