On Tue, Apr 8, 2025 at 9:18 PM PG Bug reporting form
<noreply@postgresql.org> wrote:
> cur1.execute("SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL
> SERIALIZABLE;")
> cur1.execute("START TRANSACTION;")
I think it sends an implicit BEGIN, so you're already in a
transaction, and then START TRANSACTION (= BEGIN) is ignored, and SET
SESSION will affect the *next* transaction. I bet your log says
"WARNING: there is already a transaction in progress". I think there
is a psycopg2 way to request SERIALIZABLE, something like
conn1.set_isolation_level(extensions.ISOLATION_LEVEL_SERIALIZABLE), or
you could probably use SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
instead of the SESSION version.