Re: [PATCH] plpython function causes server panic
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Hao Zhang <zhrt1446384557@gmail.com>
Cc: Andres Freund <andres@anarazel.de>, pgsql-hackers@lists.postgresql.org
Date: 2023-12-29T17:55:52Z
Lists: pgsql-hackers
Attachments
- v1-allow-subxacts-in-parallel-workers.patch (text/x-diff) patch v1
I wrote: > Hao Zhang <zhrt1446384557@gmail.com> writes: >> IMHO, there are other error reports in the function >> BeginInternalSubTransaction(), like > Sure, but all the other ones are extremely hard to hit, which is why > we didn't bother to worry about them to begin with. If we want to > make this more formally bulletproof, my inclination would be to > (a) get rid of the IsInParallelMode restriction and then (b) turn > the function into a critical section, so that any other error gets > treated as a PANIC. Here's a draft patch along this line. Basically the idea is that subtransactions used for error control are now legal in parallel mode (including in parallel workers) so long as they don't try to acquire their own XIDs. I had to clean up some error handling in xact.c, but really this is a pretty simple patch. Rather than a true critical section (ie PANIC on failure), it seemed to me to be enough to force FATAL exit if BeginInternalSubTransaction fails. Given the likelihood that our transaction state is messed up if we get a failure partway through, it's not clear to me that we could do much better than that even if we were willing to make an API change for BeginInternalSubTransaction. I haven't thought hard about what new test cases we might want to add for this. It gets through check-world as is, meaning that nobody has made any test cases exercising the previous restrictions either. There might be more documentation work to be done, too. regards, tom lane
Commits
-
Allow "internal" subtransactions in parallel mode.
- 0075d78947e3 17.0 landed
-
Tighten up application of parallel mode checks.
- 94b4f7e2a635 9.6.0 cited