Re: Re: have trouble understanding xmin and xmax with update operations from two different sessions

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: rajan <vgmonnet(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Re: have trouble understanding xmin and xmax with update operations from two different sessions
Date: 2017-07-02 18:16:09
Message-ID: CAMkU=1wP1jeHk1jQCvEhsnRC=5FwbQZ_ALkGumv4k3K8hHmR9A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Jul 1, 2017 at 8:55 PM, rajan <vgmonnet(at)gmail(dot)com> wrote:

> Thanks, Jeff. That helps understanding it 50%.
>
> *Session 2* fails to UPDATE the record which is in *(0,2)* and this tuple
> is
> marked for deletion. It means that *(0,2) never exists* when Session 2 is
> trying to perform the update.
>

That it never exists is an appearance presented to the user. The database
system works hard to maintain that illusion but the database system itself
sees through the illusion. It blocks on (0,2) waiting for session 1 to
commit, and then once that happens session 2 goes and finds the new version
of that row ((0,4) in this case) and locks it. If you use pageinspect, you
can see that (0,2) has left a pointer behind pointing to (0,4) to make it
easy to find.

Cheers,

Jeff

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message twoflower 2017-07-02 18:41:39 Re: Text search dictionary vs. the C locale
Previous Message Jerry Regan 2017-07-02 17:33:58 Using 'WITH SELECT' Results Do Not Match 'SELECT FROM <table>' Results