From: Matthias Apitz <guru@unixarea.de>
To: pgsql-general@lists.postgresql.org
Cc: Peter J. Holzer <hjp-pgsql@hjp.at>
Subject: Re: lifetime of the old CTID
Date: Wed, 6 Jul 2022 16:32:35 +0200
Message-ID: <YsWdA5bua3OZh3h6@c720-r368166> (raw)
In-Reply-To: <20220706135354.e7nxo2vyrxwqlkce@hjp.at>
References: <20220705102201.GA9@sh4-5.1blu.de>
<1c03b94b606f493bc6448b8559c4cccf806d3607.camel@cybertec.at>
<YsReJL8fvHK0D8On@c720-r368166>
<f363b79595205d42764ad7485aa46ab534f2d318.camel@cybertec.at>
<YsUfHqpk4Ll1Dej3@c720-r368166>
<9B418AE6-EA48-4493-B1D1-566708ADC9AC@thebuild.com>
<YsUpQsTgf2rv1hk+@c720-r368166>
<YsVZquEymElZ5TAK@hermes.hilbert.loc>
<20220706122600.GA24@sh4-5.1blu.de>
<20220706135354.e7nxo2vyrxwqlkce@hjp.at>
El día miércoles, julio 06, 2022 a las 03:53:54p. m. +0200, Peter J. Holzer escribió:
> On 2022-07-06 14:26:00 +0200, Matthias Apitz wrote:
> > DB layer must LOCK the row for update. It does so using the CTID. Of
> > course there is a key in the row (d01gsi, the signature of the book),
> > but this is not uniqu and can't be used to lock exactly this row for
> > update.
>
> If it isn't unique it is *not* a key. If your tables don't have a
> primary key you should seriously rethink the data model.
This Library Management System runs already for 25++ years with nearly
the same data model. We came from INFORMIX, then Oracle, then Sybase and
since 2 years are now on PostgreSQL. There was always some serial key for
the rows (I don't remember INFORMIX, but 'rowid' on Oracle,
SYB_IDENTITY_COL on Sybase and now CTID on PostgreSQL. The error we made
two years ago was not investigating carefully enough that the CTID is
pruned even before the changed row is
deleted by AUTOVACUUM. Now we know this and will deal with the problem
above the DB layer which returns now a fixed return code when the row
can not be found with its old CTID or a new CTID can not be calculated.
Said this, we can end this thread. Re-think the data model is not an
option.
matthias
--
Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045
Public GnuPG key: http://www.unixarea.de/key.pub
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, hjp-pgsql@hjp.at
Subject: Re: lifetime of the old CTID
In-Reply-To: <YsWdA5bua3OZh3h6@c720-r368166>
References: <20220705102201.GA9@sh4-5.1blu.de> <1c03b94b606f493bc6448b8559c4cccf806d3607.camel@cybertec.at> <YsReJL8fvHK0D8On@c720-r368166> <f363b79595205d42764ad7485aa46ab534f2d318.camel@cybertec.at> <YsUfHqpk4Ll1Dej3@c720-r368166> <9B418AE6-EA48-4493-B1D1-566708ADC9AC@thebuild.com> <YsUpQsTgf2rv1hk+@c720-r368166> <YsVZquEymElZ5TAK@hermes.hilbert.loc> <20220706122600.GA24@sh4-5.1blu.de> <20220706135354.e7nxo2vyrxwqlkce@hjp.at> <YsWdA5bua3OZh3h6@c720-r368166>
* 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