Re: race condition in pg_class - Mailing list pgsql-hackers

From Smolkin Grigory
Subject Re: race condition in pg_class
Date
Msg-id CAMp+ueaftSW8tnnm_zeum+hiuLaH-0VtwM19nfwDW0iLJOeLUg@mail.gmail.com
Whole thread Raw
In response to Re: race condition in pg_class  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
> ALTER TABLE ADD CONSTRAINT would certainly have taken
> AccessExclusiveLock on the "example" table, which should be sufficient
> to prevent anything else from touching its pg_class row.  The only
> mechanism I can think of that might bypass that is a manual UPDATE on
> pg_class, which would just manipulate the row as a row without concern
> for associated relation-level locks.  Any chance that somebody was
> doing something like that?

No chance. Our infrastructure dont do that, and users dont just have the privileges to mess with pg_catalog.

ср, 25 окт. 2023 г. в 21:06, Tom Lane <tgl@sss.pgh.pa.us>:
Smolkin Grigory <smallkeen@gmail.com> writes:
> We are running PG13.10 and recently we have encountered what appears to be
> a bug due to some race condition between ALTER TABLE ... ADD CONSTRAINT and
> some other catalog-writer, possibly ANALYZE.
> The problem is that after successfully creating index on relation (which
> previosly didnt have any indexes), its pg_class.relhasindex remains set to
> "false", which is illegal, I think.
> Index was built using the following statement:
> ALTER TABLE "example" ADD constraint "example_pkey" PRIMARY KEY (id);

ALTER TABLE ADD CONSTRAINT would certainly have taken
AccessExclusiveLock on the "example" table, which should be sufficient
to prevent anything else from touching its pg_class row.  The only
mechanism I can think of that might bypass that is a manual UPDATE on
pg_class, which would just manipulate the row as a row without concern
for associated relation-level locks.  Any chance that somebody was
doing something like that?

                        regards, tom lane

pgsql-hackers by date:

Previous
From: Bharath Rupireddy
Date:
Subject: Re: CRC32C Parallel Computation Optimization on ARM
Next
From: Andrei Zubkov
Date:
Subject: Re: [PATCH] Tracking statements entry timestamp in pg_stat_statements