Three more loops that let a function drop a not-yet-processed index/partition

From: Baji Shaik <baji(dot)pgdev(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>
Subject: Three more loops that let a function drop a not-yet-processed index/partition
Date: 2026-11-21 01:00:49
Message-ID: CA+fm-RMHYazqMM7xzHckJ5vuma28DYqHSyRgYmqT1WnbFyvO7g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

While looking at d94964f14f39, I noticed a similar issue in a couple of
other
code paths which fail with "could not open relation with OID ..." or a
cache lookup failure. This happens in plain REINDEX TABLE, CREATE INDEX on
a partitioned table, and ALTER TABLE ... ATTACH PARTITION.

I think we can provide a similar fix, that is, pin the not-yet-processed
relations open and release each pin right before it's processed, so the
self-drop fails cleanly via CheckTableNotInUse() instead.

Please find the attached patches.

Thoughts?

Thanks,
Baji Shaik

Attachment Content-Type Size
0001-Prevent-self-dropped-index-from-crashing-plain-REIND.patch application/octet-stream 6.3 KB
0003-Prevent-self-dropped-index-from-crashing-ATTACH-PART.patch application/octet-stream 7.8 KB
0002-Prevent-self-dropped-partition-from-crashing-CREATE-.patch application/octet-stream 6.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tender Wang 2026-11-21 02:42:10 Re: MERGE fails to reject source references in NOT MATCHED BY SOURCE actions
Previous Message Prashant Chinnam 2026-11-21 00:48:48 Re: Fix exclusion of the init fork in table_block_relation_size()