pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Matthias Apitz <guru@unixarea.de>
To: Laurenz Albe <laurenz.albe@cybertec.at>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: lifetime of the old CTID
Date: Tue, 5 Jul 2022 11:06:09 +0200
Message-ID: <20220705090609.GA9@sh4-5.1blu.de> (raw)
In-Reply-To: <03ca00a881de408016a907e31d832175b04aeac7.camel@cybertec.at>
References: <20220705075119.GA23@sh4-5.1blu.de>
	<03ca00a881de408016a907e31d832175b04aeac7.camel@cybertec.at>

El día Dienstag, Juli 05, 2022 a las 10:40:40 +0200, Laurenz Albe escribió:

> On Tue, 2022-07-05 at 09:51 +0200, Matthias Apitz wrote:
> > We're using the SQL function currtid2() to get the new CTID of a row
> > when this was UPDATEd.
> > 
> > Investigating cases of failing updates, it turns out that the old CTID
> > has only a limited lifetime; one can check this with SQL:
> > 
> > sisis=# select ctid, d01gsi from d01buch where d01gsi = '0240564';
> >     ctid    |           d01gsi            
> > ------------+-----------------------------
> >  (29036,11) | 0240564
> > 
> > now I update the row and afterwards pick up the new CTID based on the
> > old one (29036,11):
> > 
> > sisis=# UPDATE d01buch set d01ort='Wolfratshausen' where d01gsi='0240564';
> > UPDATE 1
> > sisis=# SELECT currtid2('d01buch'::text, '(29036,11)'::tid);
> >  currtid2  
> > -----------
> >  (29036,7)
> > 
> > Now I go and pick up a coffe in our kitchen and check again:
> > 
> > sisis=# SELECT currtid2('d01buch'::text, '(29036,11)'::tid);
> >   currtid2  
> > ------------
> >  (29036,11)
> > 
> > i.e. the function now only returns it argument. and not the new CTID
> > anymore.
> > 
> > Why is this? And what triggers exactly that the old CTID can't be used
> > anymore?
> 
> It is probably the fault of your coffee.

Correct, the coffee machine is broken and never does show when the
milk powder is empty already :-)

> Another explanation could be that the HOT chain was pruned while you were away.

What exactly means "the HOT chain was pruned"? What is the HOT chain?

Thanks

	matthias

-- 
Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045
Public GnuPG key: http://www.unixarea.de/key.pub





view thread (25+ messages)  latest in thread

Message-ID: <20220705090609.GA9@sh4-5.1blu.de>
Permalink:  ../20220705090609.GA9@sh4-5.1blu.de/
Also on:    postgresql.org/message-id/20220705090609.GA9@sh4-5.1blu.de

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: guru@unixarea.de, laurenz.albe@cybertec.at
  Subject: Re: lifetime of the old CTID
  In-Reply-To: <20220705090609.GA9@sh4-5.1blu.de>
  References: <20220705075119.GA23@sh4-5.1blu.de> <03ca00a881de408016a907e31d832175b04aeac7.camel@cybertec.at> <20220705090609.GA9@sh4-5.1blu.de>

* 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