Re: BUG #18882: Unexpected write skew at SERIALIZABLE with psycopg2.connect() - Mailing list pgsql-bugs

From Thomas Munro
Subject Re: BUG #18882: Unexpected write skew at SERIALIZABLE with psycopg2.connect()
Date
Msg-id CA+hUKGKp7Cj3q=fPCKKS9JSW-KiGbVNpBcRo0-nd+z_5cedoZA@mail.gmail.com
Whole thread Raw
In response to BUG #18882: Unexpected write skew at SERIALIZABLE with psycopg2.connect()  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
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.



pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #18882: Unexpected write skew at SERIALIZABLE with psycopg2.connect()
Next
From: PG Bug reporting form
Date:
Subject: BUG #18883: Epoch issue