[HACKERS] PG Manual: Clarifying the repeatable read isolation example

2014-05-27 Thread Evan Jones
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/



-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] PG Manual: Clarifying the repeatable read isolation example

2014-05-27 Thread Evan Jones
Oh yeah, I shared an office with Dan so I should have thought to check their 
paper. Oops. Thanks for the suggestion; I'll try to summarize this into 
something that is similar to the Read Committed and Serializable mode examples. 
It may take me a week or two to find the time, but thanks for the suggestions.

Evan


On May 27, 2014, at 15:32 , Heikki Linnakangas hlinnakan...@vmware.com wrote:

 I agree that's too terse. I think it would be good to actually spell out a 
 complete example of the Receipt problem in the manual. That chapter in the 
 manual contains examples of anomalities in Read Committed mode, so it would 
 be good to give a concrete example of an anomaly in Repeatable Read mode too. 
 Want to write up a docs patch?


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



-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers