pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Matthias Apitz <guru@unixarea.de>
To: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-general@lists.postgresql.org
Subject: Re: function currtid2() in SQL and ESQL/C to get the new CTID of a row
Date: Thu, 23 Jun 2022 06:57:30 +0200
Message-ID: <YrPyur/83XQRRLid@pureos> (raw)
In-Reply-To: <YrK5I1Q29P6Y0Ms1@pureos>
References: <20220601105945.GA18@sh4-5.1blu.de>
	<551140.1654091177@sss.pgh.pa.us>
	<YrK5I1Q29P6Y0Ms1@pureos>

El día miércoles, junio 22, 2022 a las 08:39:31 +0200, Matthias Apitz escribió:

> > EXEC SQL SELECT currtid2(:table ::text, :oldCTID ::tid) INTO :newCTID;
> > 
> > ...
> 
> Hello Tom,
> 
> We came accross cases where the above SELECT returns as :newCTID the
> same as the :oldCTID. The :oldCTID was picked up with FETCH from the
> CURSOR and before locking/updating the row in question we're now checking if its
> CTID has changed meanwhile we're cycling though the CURSOR. In some cases the
> CTID is returned as unchanged but a SELECT for UPDATE fails with the
> CTID. I have here an example of the ESQL/C log:
> 

We have been lucky to have the full contents of all columns of the row
in question we wanted to lock in our log files as the process saw the
row and could compare this afterwards with the actual row contents. It
turned out that the row was updated and perhaps the update transaction
not commit in the moment when the process was asking for the actual
:newCTID. We have still to investigate why this COMMIT took so long that
such a hit of two processes asking for the same row (which is like
winning the lottery on Sunday). In any case, for the moment we have no
evidence that currtid2() is the culprit.

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





view thread (4+ messages)

Message-ID: <YrPyur/83XQRRLid@pureos>
Permalink:  ../YrPyur%2F83XQRRLid@pureos/
Also on:    postgresql.org/message-id/YrPyur/83XQRRLid@pureos

 · 

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, tgl@sss.pgh.pa.us
  Subject: Re: function currtid2() in SQL and ESQL/C to get the new CTID of a row
  In-Reply-To: <YrPyur/83XQRRLid@pureos>
  References: <20220601105945.GA18@sh4-5.1blu.de> <551140.1654091177@sss.pgh.pa.us> <YrK5I1Q29P6Y0Ms1@pureos> <YrPyur/83XQRRLid@pureos>

* 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