Re: Possible G2-item at SERIALIZABLE

From: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: Possible G2-item at SERIALIZABLE
Date: 2026-06-02 23:03:46
Message-ID: CAN4CZFOMmmqbXNJx3PXwpDF4EKp-raeLkH4OmUxHGFWEW0VqqA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello

> AFAIU SSI docs do not describe this case clearly.

I agree on that part.

> Do you think that recovering serialization error with ROLLBACK TO SAVEPOINT is a bug?

It does seem like a bug to me.

s1 reads row 2, writes row 1, commits first
s2 writes row 2, then reads row 1 inside a savepoint which gets rolled back

s1 --> s2 (s1 read row 2 before s2 wrote it)
s2 --> s1 (s2 read row 1 before it saw s1's write)

Serialization is defined over what each transaction observed ("SSI is
based on the observation"), and whether those observations can be
arranged into one consistent order. I think a rolled-back read still
matters because we can't roll back the fact that the transaction
observed state.

Also, if we try to use the rolled back read for something later, like this:

SAVEPOINT s;
SELECT (balance >= 100) AS do_bonus FROM accounts WHERE id = 1 \gset
ROLLBACK TO SAVEPOINT s;
\if :do_bonus
UPDATE accounts SET bonus = bonus + 10 WHERE id = 2;
\endif
COMMIT;

it will abort on master, the questionable behavior only happens if the
read is unused. Based on this, I think even an unused read should
correctly abort for consistency.

I think we can also argue for this based on the point about locking
from README-SSI:

"Because reads in a subtransaction may cause that subtransaction
to roll back, thereby affecting what is written by the top level
transaction, predicate locks must survive a subtransaction rollback."

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message surya poondla 2026-06-02 23:44:32 Re: BUG #19382: Server crash at __nss_database_lookup
Previous Message Tom Lane 2026-06-02 19:26:12 Re: BUG #19504: Segmentation fault in plpython3u function (pg19)