PG Manual: Clarifying the repeatable read isolation example

From: Evan Jones <ej(at)evanjones(dot)ca>
To: pgsql-hackers(at)postgresql(dot)org
Subject: PG Manual: Clarifying the repeatable read isolation example
Date: 2014-05-27 19:12:22
Message-ID: 2870543D-0D4E-46AA-B71C-096C2FD6E7BC@evanjones.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Feel free to flame me if I should be posting this elsewhere, but after reading the "submitting a patch" guide, it appears I should ask for guidance here.

I was reading the Postgres MVCC documentation today (which is generally fantastic BTW), and am slightly confused by a single sentence example, describing possible read-only snapshot isolation anomalies. I would like to submit a patch to clarify this example, since I suspect others may be also confused, but to do that I need help understanding it. The example was added as part of the Serializable Snapshot Isolation patch.

Link to the commit: http://git.postgresql.org/gitweb/?p=postgresql.git;h=dafaa3efb75ce1aae2e6dbefaf6f3a889dea0d21

I'm referring to the following sentence of 13.2.2, which is still in the source tree:

http://www.postgresql.org/docs/devel/static/transaction-iso.html#XACT-REPEATABLE-READ

"For example, even a read only transaction at this level may see a control record updated to show that a batch has been completed but not see one of the detail records which is logically part of the batch because it read an earlier revision of the control record."

I do not understand how this example anomaly is possible. I'm imagining something like the following:

1. Do a bunch of work, possibly in parallel in multiple transactions, that insert/update a bunch of detail records.
2. After all that work commits, insert or update a record in the "control" table indicating that the batch completed.

Or maybe:

1. Do a batch of work and update the "control" table in a single transaction.

The guarantee that I believe REPEATABLE READ will give you in either of these case is that if you see the "control" table record, you will read all the detail records, because the control record is only written if the updated detail records have been committed. What am I not understanding?

The most widely cited read-only snapshot isolation example is the bank withdrawl example from this paper: http://www.sigmod.org/publications/sigmod-record/0409/2.ROAnomONeil.pdf . However, I suspect we can present an anomaly that doesn't require as much explanation?

Thanks,

Evan Jones

--
Work: https://www.mitro.co/ Personal: http://evanjones.ca/

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2014-05-27 19:19:26 Re: Race condition within _bt_findinsertloc()? (new page split code)
Previous Message Peter Geoghegan 2014-05-27 18:47:39 Re: Race condition within _bt_findinsertloc()? (new page split code)