pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Avoid crash when rolling back within a prepared statement. 4+ messages / 1 participants [nested] [flat]
* pgsql: Avoid crash when rolling back within a prepared statement. @ 2021-02-04 00:38 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 4+ messages in thread From: Tom Lane @ 2021-02-04 00:38 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Avoid crash when rolling back within a prepared statement. If a portal is used to run a prepared CALL or DO statement that contains a ROLLBACK, PortalRunMulti fails because the portal's statement list gets cleared by the rollback. (Since the grammar doesn't allow CALL/DO in PREPARE, the only easy way to get to this is via extended query protocol, which treats all inputs as prepared statements.) It's difficult to avoid resetting the portal early because of resource-management issues, so work around this by teaching PortalRunMulti to be wary of portal->stmts having suddenly become NIL. The crash has only been seen to occur in v13 and HEAD (as a consequence of commit 1cff1b95a having added an extra touch of portal->stmts). But even before that, the code involved touching a List that the portal no longer has any claim on. In the test case at hand, the List will still exist because of another refcount on the cached plan; but I'm far from convinced that it's impossible for the cached plan to have been dropped by the time control gets back to PortalRunMulti. Hence, backpatch to v11 where nested transactions were added. Thomas Munro and Tom Lane, per bug #16811 from James Inform Discussion: https://postgr.es/m/16811-c1b599b2c6c2d622@postgresql.org Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/9624321ec502f4e4f4722290b358694049447f95 Modified Files -------------- src/backend/tcop/pquery.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Avoid crash when rolling back within a prepared statement. @ 2021-02-04 00:38 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 4+ messages in thread From: Tom Lane @ 2021-02-04 00:38 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Avoid crash when rolling back within a prepared statement. If a portal is used to run a prepared CALL or DO statement that contains a ROLLBACK, PortalRunMulti fails because the portal's statement list gets cleared by the rollback. (Since the grammar doesn't allow CALL/DO in PREPARE, the only easy way to get to this is via extended query protocol, which treats all inputs as prepared statements.) It's difficult to avoid resetting the portal early because of resource-management issues, so work around this by teaching PortalRunMulti to be wary of portal->stmts having suddenly become NIL. The crash has only been seen to occur in v13 and HEAD (as a consequence of commit 1cff1b95a having added an extra touch of portal->stmts). But even before that, the code involved touching a List that the portal no longer has any claim on. In the test case at hand, the List will still exist because of another refcount on the cached plan; but I'm far from convinced that it's impossible for the cached plan to have been dropped by the time control gets back to PortalRunMulti. Hence, backpatch to v11 where nested transactions were added. Thomas Munro and Tom Lane, per bug #16811 from James Inform Discussion: https://postgr.es/m/16811-c1b599b2c6c2d622@postgresql.org Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/57868d957eb8320f924bc8453372cf9954e9a338 Modified Files -------------- src/backend/tcop/pquery.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Avoid crash when rolling back within a prepared statement. @ 2021-02-04 00:38 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 4+ messages in thread From: Tom Lane @ 2021-02-04 00:38 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Avoid crash when rolling back within a prepared statement. If a portal is used to run a prepared CALL or DO statement that contains a ROLLBACK, PortalRunMulti fails because the portal's statement list gets cleared by the rollback. (Since the grammar doesn't allow CALL/DO in PREPARE, the only easy way to get to this is via extended query protocol, which treats all inputs as prepared statements.) It's difficult to avoid resetting the portal early because of resource-management issues, so work around this by teaching PortalRunMulti to be wary of portal->stmts having suddenly become NIL. The crash has only been seen to occur in v13 and HEAD (as a consequence of commit 1cff1b95a having added an extra touch of portal->stmts). But even before that, the code involved touching a List that the portal no longer has any claim on. In the test case at hand, the List will still exist because of another refcount on the cached plan; but I'm far from convinced that it's impossible for the cached plan to have been dropped by the time control gets back to PortalRunMulti. Hence, backpatch to v11 where nested transactions were added. Thomas Munro and Tom Lane, per bug #16811 from James Inform Discussion: https://postgr.es/m/16811-c1b599b2c6c2d622@postgresql.org Branch ------ REL_12_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/77e760d5cc71b8605762b770f539ea77b8db64f1 Modified Files -------------- src/backend/tcop/pquery.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Avoid crash when rolling back within a prepared statement. @ 2021-02-04 00:38 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 4+ messages in thread From: Tom Lane @ 2021-02-04 00:38 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Avoid crash when rolling back within a prepared statement. If a portal is used to run a prepared CALL or DO statement that contains a ROLLBACK, PortalRunMulti fails because the portal's statement list gets cleared by the rollback. (Since the grammar doesn't allow CALL/DO in PREPARE, the only easy way to get to this is via extended query protocol, which treats all inputs as prepared statements.) It's difficult to avoid resetting the portal early because of resource-management issues, so work around this by teaching PortalRunMulti to be wary of portal->stmts having suddenly become NIL. The crash has only been seen to occur in v13 and HEAD (as a consequence of commit 1cff1b95a having added an extra touch of portal->stmts). But even before that, the code involved touching a List that the portal no longer has any claim on. In the test case at hand, the List will still exist because of another refcount on the cached plan; but I'm far from convinced that it's impossible for the cached plan to have been dropped by the time control gets back to PortalRunMulti. Hence, backpatch to v11 where nested transactions were added. Thomas Munro and Tom Lane, per bug #16811 from James Inform Discussion: https://postgr.es/m/16811-c1b599b2c6c2d622@postgresql.org Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/1c3a877469a93ae2e753da026bd1b939d8cf7f11 Modified Files -------------- src/backend/tcop/pquery.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2021-02-04 00:38 UTC | newest] Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2021-02-04 00:38 pgsql: Avoid crash when rolling back within a prepared statement. Tom Lane <tgl@sss.pgh.pa.us> 2021-02-04 00:38 pgsql: Avoid crash when rolling back within a prepared statement. Tom Lane <tgl@sss.pgh.pa.us> 2021-02-04 00:38 pgsql: Avoid crash when rolling back within a prepared statement. Tom Lane <tgl@sss.pgh.pa.us> 2021-02-04 00:38 pgsql: Avoid crash when rolling back within a prepared statement. 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