pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix plancache refcount leak after error in ExecuteQuery. 6+ messages / 1 participants [nested] [flat]
* pgsql: Fix plancache refcount leak after error in ExecuteQuery. @ 2021-06-16 23:30 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2021-06-16 23:30 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix plancache refcount leak after error in ExecuteQuery. When stuffing a plan from the plancache into a Portal, one is not supposed to risk throwing an error between GetCachedPlan and PortalDefineQuery; if that happens, the plan refcount incremented by GetCachedPlan will be leaked. I managed to break this rule while refactoring code in 9dbf2b7d7. There is no visible consequence other than some memory leakage, and since nobody is very likely to trigger the relevant error conditions many times in a row, it's not surprising we haven't noticed. Nonetheless, it's a bug, so rearrange the order of operations to remove the hazard. Noted on the way to looking for a better fix for bug #17053. This mistake is pretty old, so back-patch to all supported branches. Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/131ea3e908d3c97a2fe1ab25cce5046dd5cb905f Modified Files -------------- src/backend/commands/prepare.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix plancache refcount leak after error in ExecuteQuery. @ 2021-06-16 23:30 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2021-06-16 23:30 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix plancache refcount leak after error in ExecuteQuery. When stuffing a plan from the plancache into a Portal, one is not supposed to risk throwing an error between GetCachedPlan and PortalDefineQuery; if that happens, the plan refcount incremented by GetCachedPlan will be leaked. I managed to break this rule while refactoring code in 9dbf2b7d7. There is no visible consequence other than some memory leakage, and since nobody is very likely to trigger the relevant error conditions many times in a row, it's not surprising we haven't noticed. Nonetheless, it's a bug, so rearrange the order of operations to remove the hazard. Noted on the way to looking for a better fix for bug #17053. This mistake is pretty old, so back-patch to all supported branches. Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/d03a41d1c860ffc97bda40a3673698d4044f5c88 Modified Files -------------- src/backend/commands/prepare.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix plancache refcount leak after error in ExecuteQuery. @ 2021-06-16 23:30 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2021-06-16 23:30 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix plancache refcount leak after error in ExecuteQuery. When stuffing a plan from the plancache into a Portal, one is not supposed to risk throwing an error between GetCachedPlan and PortalDefineQuery; if that happens, the plan refcount incremented by GetCachedPlan will be leaked. I managed to break this rule while refactoring code in 9dbf2b7d7. There is no visible consequence other than some memory leakage, and since nobody is very likely to trigger the relevant error conditions many times in a row, it's not surprising we haven't noticed. Nonetheless, it's a bug, so rearrange the order of operations to remove the hazard. Noted on the way to looking for a better fix for bug #17053. This mistake is pretty old, so back-patch to all supported branches. Branch ------ REL_12_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/17d962ccae33db4526d08f909eea536a2a2383cf Modified Files -------------- src/backend/commands/prepare.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix plancache refcount leak after error in ExecuteQuery. @ 2021-06-16 23:30 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2021-06-16 23:30 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix plancache refcount leak after error in ExecuteQuery. When stuffing a plan from the plancache into a Portal, one is not supposed to risk throwing an error between GetCachedPlan and PortalDefineQuery; if that happens, the plan refcount incremented by GetCachedPlan will be leaked. I managed to break this rule while refactoring code in 9dbf2b7d7. There is no visible consequence other than some memory leakage, and since nobody is very likely to trigger the relevant error conditions many times in a row, it's not surprising we haven't noticed. Nonetheless, it's a bug, so rearrange the order of operations to remove the hazard. Noted on the way to looking for a better fix for bug #17053. This mistake is pretty old, so back-patch to all supported branches. Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/9cf163266017ec6d0e190313cce1d417cbf4a549 Modified Files -------------- src/backend/commands/prepare.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix plancache refcount leak after error in ExecuteQuery. @ 2021-06-16 23:30 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2021-06-16 23:30 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix plancache refcount leak after error in ExecuteQuery. When stuffing a plan from the plancache into a Portal, one is not supposed to risk throwing an error between GetCachedPlan and PortalDefineQuery; if that happens, the plan refcount incremented by GetCachedPlan will be leaked. I managed to break this rule while refactoring code in 9dbf2b7d7. There is no visible consequence other than some memory leakage, and since nobody is very likely to trigger the relevant error conditions many times in a row, it's not surprising we haven't noticed. Nonetheless, it's a bug, so rearrange the order of operations to remove the hazard. Noted on the way to looking for a better fix for bug #17053. This mistake is pretty old, so back-patch to all supported branches. Branch ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/a6f7745a3e7f89deeb45e78a4bc1b7f39b2d699a Modified Files -------------- src/backend/commands/prepare.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Fix plancache refcount leak after error in ExecuteQuery. @ 2021-06-16 23:30 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2021-06-16 23:30 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix plancache refcount leak after error in ExecuteQuery. When stuffing a plan from the plancache into a Portal, one is not supposed to risk throwing an error between GetCachedPlan and PortalDefineQuery; if that happens, the plan refcount incremented by GetCachedPlan will be leaked. I managed to break this rule while refactoring code in 9dbf2b7d7. There is no visible consequence other than some memory leakage, and since nobody is very likely to trigger the relevant error conditions many times in a row, it's not surprising we haven't noticed. Nonetheless, it's a bug, so rearrange the order of operations to remove the hazard. Noted on the way to looking for a better fix for bug #17053. This mistake is pretty old, so back-patch to all supported branches. Branch ------ REL9_6_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/c50596cdc9234b15359761bdeddec5395fbd57c5 Modified Files -------------- src/backend/commands/prepare.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2021-06-16 23:30 UTC | newest] Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2021-06-16 23:30 pgsql: Fix plancache refcount leak after error in ExecuteQuery. Tom Lane <tgl@sss.pgh.pa.us> 2021-06-16 23:30 pgsql: Fix plancache refcount leak after error in ExecuteQuery. Tom Lane <tgl@sss.pgh.pa.us> 2021-06-16 23:30 pgsql: Fix plancache refcount leak after error in ExecuteQuery. Tom Lane <tgl@sss.pgh.pa.us> 2021-06-16 23:30 pgsql: Fix plancache refcount leak after error in ExecuteQuery. Tom Lane <tgl@sss.pgh.pa.us> 2021-06-16 23:30 pgsql: Fix plancache refcount leak after error in ExecuteQuery. Tom Lane <tgl@sss.pgh.pa.us> 2021-06-16 23:30 pgsql: Fix plancache refcount leak after error in ExecuteQuery. 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