postgresql/src/backend/access
Tom Lane 0075d78947 Allow "internal" subtransactions in parallel mode.
Allow use of BeginInternalSubTransaction() in parallel mode, so long
as the subtransaction doesn't attempt to acquire an XID or increment
the command counter.  Given those restrictions, the other parallel
processes don't need to know about the subtransaction at all, so
this should be safe.  The benefit is that it allows subtransactions
intended for error recovery, such as pl/pgsql exception blocks,
to be used in PARALLEL SAFE functions.

Another reason for doing this is that the API of
BeginInternalSubTransaction() doesn't allow reporting failure.
pl/python for one, and perhaps other PLs, copes very poorly with an
error longjmp out of BeginInternalSubTransaction().  The headline
feature of this patch removes the only easily-triggerable failure
case within that function.  There remain some resource-exhaustion
and similar cases, which we now deal with by promoting them to FATAL
errors, so that callers need not try to clean up.  (It is likely
that such errors would leave us with corrupted transaction state
inside xact.c, making recovery difficult if not impossible anyway.)

Although this work started because of a report of a pl/python crash,
we're not going to do anything about that in the back branches.
Back-patching this particular fix is obviously not very wise.
While we could contemplate some narrower band-aid, pl/python is
already an untrusted language, so it seems okay to classify this
as a "so don't do that" case.

Patch by me, per report from Hao Zhang.  Thanks to Robert Haas for
review.

Discussion: https://postgr.es/m/CALY6Dr-2yLVeVPhNMhuBnRgOZo1UjoTETgtKBx1B2gUi8yy+3g@mail.gmail.com
2024-03-28 12:43:10 -04:00
..
brin Make the order of the header file includes consistent 2024-03-13 15:07:00 +01:00
common Rethink create and attach APIs of shared TidStore. 2024-03-28 10:03:28 +09:00
gin Remove unused #include's from backend .c files 2024-03-04 12:02:20 +01:00
gist Merge prune, freeze and vacuum WAL record formats 2024-03-25 14:59:58 +02:00
hash Merge prune, freeze and vacuum WAL record formats 2024-03-25 14:59:58 +02:00
heap Remove obsolete comment about VACUUM retrying pruning 2024-03-28 10:18:48 +02:00
index Remove unused #include's from backend .c files 2024-03-04 12:02:20 +01:00
nbtree Fix an oversight in refactoring in 06b10f80ba. 2024-03-22 15:25:53 +02:00
rmgrdesc Merge prune, freeze and vacuum WAL record formats 2024-03-25 14:59:58 +02:00
sequence Fix comment thinko in sequence.c 2024-02-27 08:19:39 +09:00
spgist Make the order of the header file includes consistent 2024-03-13 15:07:00 +01:00
table Allow locking updated tuples in tuple_update() and tuple_delete() 2024-03-26 01:27:56 +02:00
tablesample Remove unused #include's from backend .c files 2024-03-04 12:02:20 +01:00
transam Allow "internal" subtransactions in parallel mode. 2024-03-28 12:43:10 -04:00
Makefile Introduce sequence_*() access functions 2024-02-26 16:04:59 +09:00
meson.build Introduce sequence_*() access functions 2024-02-26 16:04:59 +09:00