fix crash with Python 3.11

From: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: fix crash with Python 3.11
Date: 2021-12-22 08:24:06
Message-ID: 3375ffd8-d71c-2565-e348-a597d6e739e3@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


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.

Attachment Content-Type Size
v1-0001-Set-Python-exception-after-failed-commit-or-rollb.patch text/plain 8.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Sharma 2021-12-22 08:30:48 Re: Checkpointer crashes with "PANIC: could not fsync file "pg_tblspc/.."
Previous Message Ashutosh Sharma 2021-12-22 08:18:54 Re: [Proposal] Fully WAL logged CREATE DATABASE - No Checkpoints