pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Mariel Cherkassky <mariel.cherkassky@gmail.com>
To: pgsql-admin@lists.postgresql.org
Subject: Re: unclear behavior xmax/xmin
Date: Sun, 18 Nov 2018 20:04:49 +0100
Message-ID: <8981328ca8d9ad247ecd203c9f9f206fb63b9e30.camel@cybertec.at> (raw)
In-Reply-To: <CA+t6e1mvt0Fw-d2_vgKHBO=Wn-yFinAq7DTDjC-wbfD=+mmjCA@mail.gmail.com>
References: <CA+t6e1mvt0Fw-d2_vgKHBO=Wn-yFinAq7DTDjC-wbfD=+mmjCA@mail.gmail.com>

Mariel Cherkassky wrote:
> - I started transaction A and deleted one row but I didnt commit.
>   Afterwards I rolledback the transaction but the xmax of the row was set
>   to the txid of transaction A. I opened a new session and run VACUUM on the table.
>   However, that record wasnt deleted but the xmax was still set to
>   transaction`s A txid. Is that a bug ? the vacuum process shouldnt delete
>   that row because it has an old xmax (there arent any younger transactions).
>   In addition, I'm still capable of seeing the record (because of the rollback..)
>   but my txid is bigger then the xmax of the record. ? Is that a bug ?

I wrote about that a whil ago, see
https://www.cybertec-postgresql.com/en/whats-in-an-xmax/

> -When I run an update basically its just like running an  insert and delete
>  (the xmax of the old row is changed to the transaction`s txid and the new row
>  contains xmin same as txid of the current transaction and xmax is set to 0).
>  However, when I query the table (didnt commit yet) I dont see the old record.
>  Is there a way to see it ? Why is that ? I thought that I should see the table
>  with a non zero value in the xmax col.

In the transaction that ran the UPDATE, you will of course see the updated
row.  Everything else would be inconsistent.

You have to start a second database session if you want to see the previous
row version.

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com





view thread (5+ messages)  latest in thread

Message-ID: <8981328ca8d9ad247ecd203c9f9f206fb63b9e30.camel@cybertec.at>
Permalink:  ../8981328ca8d9ad247ecd203c9f9f206fb63b9e30.camel@cybertec.at/
Also on:    postgresql.org/message-id/8981328ca8d9ad247ecd203c9f9f206fb63b9e30.camel@cybertec.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: laurenz.albe@cybertec.at, mariel.cherkassky@gmail.com, pgsql-admin@lists.postgresql.org
  Subject: Re: unclear behavior xmax/xmin
  In-Reply-To: <8981328ca8d9ad247ecd203c9f9f206fb63b9e30.camel@cybertec.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox