Re: Potential G2-item cycles under serializable isolation

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Kyle Kingsbury <aphyr(at)jepsen(dot)io>
Cc: PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: Potential G2-item cycles under serializable isolation
Date: 2020-06-05 00:20:22
Message-ID: CAH2-WznURpoCuxHV28kBsNwi9TDM0zMkrA8JjTvymXaYfyCOkQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Jun 4, 2020 at 3:11 PM Kyle Kingsbury <aphyr(at)jepsen(dot)io> wrote:
> Yes! It's not always this obvious--G2-item encompasses any dependency cycle
> between transactions such that at least one dependency involves a transaction
> writing state which was not observed by some (ostensibly prior) transaction's
> read. We call these "rw dependencies" in the paper, because they involve a read
> which must have occurred before a write. Another way to think of G2-item is "A
> transaction failed to see something that happened in its logical past".

Are you familiar with the paper "Serializable Snapshot Isolation in
PostgreSQL"? You might find it helpful:

http://vldb.org/pvldb/vol5/p1850_danrkports_vldb2012.pdf

Is there a difference between "rw dependencies" as you understand the
term, and what the paper calls "rw-antidependencies"?

> A special case of G2-item, G-single, is commonly known as read skew. In Elle, we
> tag G-single separately, so all the G2-item anomalies reported actually involve
> 2+ rw dependencies, not just 1+. I haven't seen G-single yet, which is
> good--that means Postgres isn't violating SI, just SSI. Or, of course, the test
> itself could be broken--maybe the SQL statements themselves are subtly wrong, or
> our inference is incorrect.

I'm glad that you don't suspect snapshot isolation has been violated.
Frankly I'd be astonished if Postgres is found to be violating SI
here. Anything is possible, but if that happened then it would almost
certainly be far more obvious. The way MVCC works in Postgres is
relatively simple. If an xact in repeatable read mode really did
return a row that wasn't visible to its snapshot, then it's probably
just as likely to return two row versions for the same logical row, or
zero row versions. These are symptoms of various types of data
corruption that we see from time to time. Note, in particular, that
violating SI cannot happen because a transaction released a lock in an
index when it shouldn't have -- because we simply don't have those.
(Actually, we do have something called predicate locks, but those are
not at all like 2PL index value locks -- see the paper I linked to for
more.)

> Give Jepsen a138843d a shot!
>
> 1553 jepsen process 27 16 LOG: execute <unnamed>: select (val) from txn0 where
> sk = $1
>
> 1553 jepsen process 27 17 DETAIL: parameters: $1 = '9'

Attached is:

* A Jepsen failure of the kind we've been talking about

* Log output from Postgres that shows all log lines with the
relevant-to-failure Jepsen worker numbers, as discussed. This is
interleaved based on timestamp order.

Can you explain the anomaly with reference to the actual SQL queries
executed in the log? Is the information that I've provided sufficient?

--
Peter Geoghegan

Attachment Content-Type Size
jepsen-failure.txt text/plain 1.8 KB
process_23_5.log.bz2 application/x-bzip2 18.1 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2020-06-05 01:22:01 Re: Explicit deterministic COLLATE fails with pattern matching operations on column with non-deterministic collation
Previous Message David Rowley 2020-06-05 00:18:28 Re: posgres 12 bug (partitioned table)