Re: Confusions regards serializable transaction

From: Hannah Huang <hannah(dot)huang(dot)y(at)gmail(dot)com>
To: Peter Geoghegan <pg(at)bowt(dot)ie>
Cc: pgsql-novice(at)lists(dot)postgresql(dot)org
Subject: Re: Confusions regards serializable transaction
Date: 2020-09-04 06:05:50
Message-ID: 31DA4198-1B8E-4999-9A19-49AD87F36BDB@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

> On 4 Sep 2020, at 2:21 pm, Peter Geoghegan <pg(at)bowt(dot)ie> wrote:
>
> On Thu, Sep 3, 2020 at 5:20 PM Hannah Huang <hannah(dot)huang(dot)y(at)gmail(dot)com> wrote:
>> I’m confused about what will trigger the serializable error. My test environment is PG v12.
>>
>> This is how you can produce the test table:
>
> Serializable isolation level promises to emulate serial transaction
> execution for all committed transactions. I believe that your example
> does not show behavior that breaks that specific promise.
>
> --
> Peter Geoghegan

Hi Peter,
Thank you very much for replying my question.

My confusion is actually:

Transaction B updated the n value of id 2, while transaction A needs to update n value for id 1 referencing the n value of id 2.

If the transaction is executed in a serialized way, then the n value of id 2 will be changed in transaction B first, and the change will be reflected in the value of id 1in transaction A. However, the two transactions are not executed concurrently - transaction A executed successfully without seeing changes made in transaction B. Is that a break of serializable isolation level?

Thanks,
Hannah

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Laurenz Albe 2020-09-04 12:07:01 Re: Confusions regards serializable transaction
Previous Message Peter Geoghegan 2020-09-04 04:21:57 Re: Confusions regards serializable transaction