Re: fix crash with Python 3.11
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Cc: exclusion@gmail.com, pgsql-hackers@lists.postgresql.org
Date: 2022-02-23T19:31:22Z
Lists: pgsql-hackers
Attachments
- start-new-xact-in-SPI-commit-rollback-1.patch (text/x-diff) patch
I wrote: > We could provide a simplified API in which SPI_start_transaction is > automatically included for either success or failure, so that the caller > doesn't have the delayed-cleanup responsibility. I'm not actually sure > that there is any situation where that couldn't be done, but putting it > into the existing functions would be a API break (... unless we turn > SPI_start_transaction into a no-op, which might be OK?) Basically this'd > be making the behavior of SPI_commit_and_chain the norm, except you'd > have the option of reverting to default transaction settings instead > of the previous ones. > So basically where we'd end up is that plpython would do about what > you show in your patch, but then there's additional work needed in > spi.c so that we're not leaving the rest of the system in a bad state. Here's a draft patch that works that way. I haven't tested it against Python 3.11, but it handles the case I showed upthread (now incorporated as a regression test), as well as Alexander's repeat-till-stack-overflow problem. The one thing I found that I wasn't expecting is that AtEOXact_SPI is quite a few bricks shy of a load: it doesn't handle cases where some atomic contexts are atop an internal_xact one. That happens in the new test case because the error is thrown from RI triggers that themselves use SPI. This is draft mainly in that * I didn't touch spi.sgml yet. * It might be a good idea to add parallel test cases for the other PLs. * I'm not satisfied with using static storage for SaveTransactionCharacteristics/RestoreTransactionCharacteristics. It'd be better for them to use a struct allocated locally in the caller. That would be a simple enough change, but also an API break; on the other hand, I really doubt anything outside core code is calling those. Anyone object to changing them? I'm not sure how to proceed with this. It's kind of a large change to be putting into back branches, but our hands will be forced once Python 3.11 is out. Maybe put it in HEAD now, and plan to back-patch in a few months? regards, tom lane
Commits
-
Re-add SPICleanup for ABI compatibility in stable branch
- 6d61aef5dbb6 11.17 landed
- 9af9e2094dcf 12.12 landed
- b2c8d56618b8 13.8 landed
- 8657946d375f 14.5 landed
-
Fix SPI's handling of errors during transaction commit.
- cfc86f987349 13.8 landed
- 2f6b8c287b88 11.17 landed
- 293f5c5f496c 12.12 landed
- 604651880c71 14.5 landed
- 2e517818f4af 15.0 landed
-
Don't use static storage for SaveTransactionCharacteristics().
- 12d768e70497 15.0 landed