fix crash with Python 3.11
Peter Eisentraut <peter.eisentraut@enterprisedb.com>
From: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2021-12-22T08:24:06Z
Lists: pgsql-hackers
Attachments
- v1-0001-Set-Python-exception-after-failed-commit-or-rollb.patch (text/plain) patch v1-0001
This patch needs another close pass and possibly some refactoring to avoid copy-and-paste, but I'm putting this out here, since people are already testing with Python 3.11 and will surely run into this problem. The way plpy.commit() and plpy.rollback() handle errors is not ideal. They end up just longjmping back to the main loop, without telling the Python interpreter about it. This hasn't been a problem so far, apparently, but with Python 3.11-to-be, this appears to cause corruption in the state of the Python interpreter. This is readily reproducible and will cause crashes in the plpython_transaction test. The fix is that we need to catch the PostgreSQL error and turn it into a Python exception, like we do for other places where plpy.* methods call into PostgreSQL internals.
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