Re: race condition in pg_class

From: Noah Misch <noah(at)leadboat(dot)com>
To: Alexander Lakhin <exclusion(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org, Smolkin Grigory <smallkeen(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>
Subject: Re: race condition in pg_class
Date: 2024-07-03 23:09:54
Message-ID: 20240703230954.d7.nmisch@google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jul 03, 2024 at 06:00:00AM +0300, Alexander Lakhin wrote:
> 29.06.2024 05:42, Noah Misch wrote:
> > Good point, any effort on (2) would be wasted once the fixes get certified. I
> > pushed (1). I'm attaching the rebased fix patches.
>
> Please look at a new anomaly, introduced by inplace110-successors-v5.patch:
> CREATE TABLE t (i int) PARTITION BY LIST(i);
> CREATE TABLE p1 (i int);
> ALTER TABLE t ATTACH PARTITION p1 FOR VALUES IN (1);
> ALTER TABLE t DETACH PARTITION p1;
> ANALYZE t;
>
> triggers unexpected
> ERROR:  tuple to be updated was already modified by an operation triggered by the current command

Thanks. Today, it's okay to issue heap_inplace_update() after heap_update()
without an intervening CommandCounterIncrement(). The patch makes the CCI
required. The ANALYZE in your example reaches this with a heap_update to set
relhassubclass=f. I've fixed this by just adding a CCI (and adding to the
tests in vacuum.sql).

The alternative would be to allow inplace updates on TM_SelfModified tuples.
I can't think of a specific problem with allowing that, but I feel that would
make system state interactions harder to reason about. It might be optimal to
allow that in back branches only, to reduce the chance of releasing a bug like
the one you found.

Attachment Content-Type Size
inplace090-LOCKTAG_TUPLE-eoxact-v6.patch text/plain 1.2 KB
inplace110-successors-v6.patch text/plain 47.1 KB
inplace120-locktag-v6.patch text/plain 42.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2024-07-04 00:51:16 Re: Internal error codes triggered by tests
Previous Message Heikki Linnakangas 2024-07-03 22:54:18 Cleanup: PGProc->links doesn't need to be the first field anymore