Re: Strange Behavior with Serializable Transcations - Mailing list pgsql-general

From Tom Lane
Subject Re: Strange Behavior with Serializable Transcations
Date
Msg-id 19267.1151634422@sss.pgh.pa.us
Whole thread Raw
In response to Re: Strange Behavior with Serializable Transcations  ("Qingqing Zhou" <zhouqq@cs.toronto.edu>)
List pgsql-general
"Qingqing Zhou" <zhouqq@cs.toronto.edu> writes:
> "Tom Lane" <tgl@sss.pgh.pa.us> wrote
>> Right, the snapshot does not become set until you do a non-utility
>> command (normally, SELECT/INSERT/UPDATE/DELETE).  This is a feature, not
>> a bug, because it lets the transaction take table locks before its
>> snapshot becomes set.

> Hm, mostly I understand it as an optimization. What do you mean by "it lets
> the transaction take table locks before its snapshot becomes set"?  If we
> take a snapshot at BEGIN, then the transaction can't take table locks?

It can, but there are cases where you want the lock to be taken before
the snapshot is set.  Otherwise, there could be committed changes in the
database that you can't see in your snapshot.  I think there are some
examples in the manual, or check the archives.

            regards, tom lane

pgsql-general by date:

Previous
From: "Qingqing Zhou"
Date:
Subject: Re: Strange Behavior with Serializable Transcations
Next
From: Chris
Date:
Subject: Re: psql -h host ...