Re: Lock table, Select for update and Serialization error

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Albe Laurenz" <all(at)adv(dot)magwien(dot)gv(dot)at>
Cc: sudhirj(at)cse(dot)iitb(dot)ac(dot)in, pgsql-general(at)postgresql(dot)org
Subject: Re: Lock table, Select for update and Serialization error
Date: 2007-05-22 15:08:08
Message-ID: 13379.1179846488@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Albe Laurenz" <all(at)adv(dot)magwien(dot)gv(dot)at> writes:
> You see, there is a difference. In case a) the serializable transaction
> will very likely fail if there are many concurrent changes on the table.
> In case b), the serializable transaction will always succeed, while
> all concurrent updates must wait.

The critical point here is that LOCK TABLE commands at the start of a
serializable transaction are performed *before* taking the transaction's
snapshot (the snap happens at the first regular DML command). They not
only protect against post-snap changes as shown by Albe's example, but
against uncommitted changes that were made before transaction start
(by making the serializable xact wait until those changes are committed
or aborted before it takes its snap).

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2007-05-22 15:09:20 Re: Problem with pg_dump
Previous Message znahor-news 2007-05-22 14:36:49 Problem with pg_dump