Re: Repeatable Read Isolation Level "transaction start time"

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Peter J(dot) Holzer" <hjp-pgsql(at)hjp(dot)at>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Repeatable Read Isolation Level "transaction start time"
Date: 2024-09-25 22:09:44
Message-ID: 152525.1727302184@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Peter J. Holzer" <hjp-pgsql(at)hjp(dot)at> writes:
> On 2024-09-25 13:53:30 -0700, Christophe Pettus wrote:
>> This might well be a failure of imagination on my part, but when would
>> it pragmatically matter that the snapshot is taken at the first
>> statement as opposed to at BEGIN?

> It may make a difference if you're comparing timestamps.

> For example, if you're using isolation level REPEATABLE READ and
> (mistakenly) assume that the snapshot is taken at BEGIN, you would
> expect any transaction_timestamp() written by a different transaction
> and readable by this transaction to be earlier than the
> transaction_timestamp() of this transaction.

> But that's wrong because the other transaction could have happened
> entirely in the time between your BEGIN and the statement which actually
> triggers the snapshot.

I don't find that hugely compelling, because there's always going
to be some skew between the time we read the clock for the timestamp
and the time we obtain the snapshot. Admittedly, that would normally
not be a very long interval if BEGIN did both things ... but on a
busy system you could lose the CPU for awhile in between.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Muhammad Usman Khan 2024-09-26 03:34:27 Re: MError after replication in postgresql
Previous Message Peter J. Holzer 2024-09-25 21:55:54 Re: Repeatable Read Isolation Level "transaction start time"