pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix problems with auto-held portals. 2+ messages / 1 participants [nested] [flat]
* pgsql: Fix problems with auto-held portals. @ 2019-04-19 15:20 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2019-04-19 15:20 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix problems with auto-held portals. HoldPinnedPortals() did things in the wrong order: it must not mark a portal autoHeld until it's been successfully held. Otherwise, a failure while persisting the portal results in a server crash because we think the portal is in a good state when it's not. Also add a check that portal->status is READY before attempting to hold a pinned portal. We have such a check before the only other use of HoldPortal(), so it seems unwise not to check it here. Lastly, rethink the responsibility for where to call HoldPinnedPortals. The comment for it imagined that it was optional for any individual PL to call it or not, but that cannot be the case: if some outer level of procedure has a pinned portal, failing to persist it when an inner procedure commits is going to be trouble. Let's have SPI do it instead of the individual PLs. That's not a complete solution, since in theory a PL might not be using SPI to perform commit/rollback, but such a PL is going to have to be aware of lots of related requirements anyway. (This change doesn't cause an API break for any external PLs that might be calling HoldPinnedPortals per the old regime, because calling it twice during a commit or rollback sequence won't hurt.) Per bug #15703 from Julian Schauder. Back-patch to v11 where this code came in. Discussion: https://postgr.es/m/15703-c12c5bc0ea34ba26@postgresql.org Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/4d5840cea96d7f893389664dd423716b38fded7a Modified Files -------------- src/backend/executor/spi.c | 17 +++++++++ src/backend/utils/mmgr/portalmem.c | 26 +++++++++---- src/pl/plperl/plperl.c | 4 -- .../plpgsql/src/expected/plpgsql_transaction.out | 44 ++++++++++++++++++++++ src/pl/plpgsql/src/pl_exec.c | 4 -- src/pl/plpgsql/src/sql/plpgsql_transaction.sql | 38 +++++++++++++++++++ src/pl/plpython/plpy_plpymodule.c | 4 -- 7 files changed, 117 insertions(+), 20 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
* pgsql: Fix problems with auto-held portals. @ 2019-04-19 15:20 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2019-04-19 15:20 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix problems with auto-held portals. HoldPinnedPortals() did things in the wrong order: it must not mark a portal autoHeld until it's been successfully held. Otherwise, a failure while persisting the portal results in a server crash because we think the portal is in a good state when it's not. Also add a check that portal->status is READY before attempting to hold a pinned portal. We have such a check before the only other use of HoldPortal(), so it seems unwise not to check it here. Lastly, rethink the responsibility for where to call HoldPinnedPortals. The comment for it imagined that it was optional for any individual PL to call it or not, but that cannot be the case: if some outer level of procedure has a pinned portal, failing to persist it when an inner procedure commits is going to be trouble. Let's have SPI do it instead of the individual PLs. That's not a complete solution, since in theory a PL might not be using SPI to perform commit/rollback, but such a PL is going to have to be aware of lots of related requirements anyway. (This change doesn't cause an API break for any external PLs that might be calling HoldPinnedPortals per the old regime, because calling it twice during a commit or rollback sequence won't hurt.) Per bug #15703 from Julian Schauder. Back-patch to v11 where this code came in. Discussion: https://postgr.es/m/15703-c12c5bc0ea34ba26@postgresql.org Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/0998f32ca3c4a8368217c6a14eb995ece9c580c6 Modified Files -------------- src/backend/executor/spi.c | 17 +++++++++ src/backend/utils/mmgr/portalmem.c | 26 +++++++++---- src/pl/plperl/plperl.c | 4 -- .../plpgsql/src/expected/plpgsql_transaction.out | 44 ++++++++++++++++++++++ src/pl/plpgsql/src/pl_exec.c | 4 -- src/pl/plpgsql/src/sql/plpgsql_transaction.sql | 38 +++++++++++++++++++ src/pl/plpython/plpy_plpymodule.c | 4 -- 7 files changed, 117 insertions(+), 20 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2019-04-19 15:20 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2019-04-19 15:20 pgsql: Fix problems with auto-held portals. Tom Lane <tgl@sss.pgh.pa.us> 2019-04-19 15:20 pgsql: Fix problems with auto-held portals. 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