Re: postgresql's MVCC implementation - Mailing list pgsql-general

From Tom Lane
Subject Re: postgresql's MVCC implementation
Date
Msg-id 29993.1215355209@sss.pgh.pa.us
Whole thread Raw
In response to postgresql's MVCC implementation  (Kent Tong <kent@cpttm.org.mo>)
Responses Re: postgresql's MVCC implementation
List pgsql-general
Kent Tong <kent@cpttm.org.mo> writes:
> 1: T1 sets isolation to serializable & begins a transaction
> 2: T2 sets isolation to serializable & begins a transaction
> 3: T1 reads X into v1
> 4: T2 reads Y into v2
> 5: T1 writes v1 into Y
> 6: T2 writes v2 into X
> 7: T1 commits
> 8: T2 commits

> Obviously, this sequence is also not a serializable execution. However, it
> is allowed by
> PostgreSQL. Moreover, according to the MVCC reference above, step 5 should
> really
> fail because the read timestamp of Y is that of T2, which is greater than
> that of T1.

If you want that to fail, use a SELECT FOR UPDATE at steps 3/4.

My interpretation of MVCC is that the above example isn't even
meaningful, because it assumes that "writing into Y" is an overwrite,
which it is not in Postgres --- that is, if T2 reads Y again, it'll
get the same value as before.

            regards, tom lane

pgsql-general by date:

Previous
From: Susan Crayne
Date:
Subject: Re: Installation problem -- another installation is in progress
Next
From: Scott Frankel
Date:
Subject: Re: roll back to 8.1 for PyQt driver work-around