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

Started by Baji Shaik1 day ago2 messageshackers
Jump to latest
#1Baji Shaik
baji.pgdev@gmail.com

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

Attachments:

t259613_1
0001-Prevent-self-dropped-index-from-crashing-plain-REIND.patchapplication/octet-stream; name=0001-Prevent-self-dropped-index-from-crashing-plain-REIND.patchDownload+79-2
0003-Prevent-self-dropped-index-from-crashing-ATTACH-PART.patchapplication/octet-stream; name=0003-Prevent-self-dropped-index-from-crashing-ATTACH-PART.patchDownload+85-2
0002-Prevent-self-dropped-partition-from-crashing-CREATE-.patchapplication/octet-stream; name=0002-Prevent-self-dropped-partition-from-crashing-CREATE-.patchDownload+66-1
#2Michael Paquier
michael@paquier.xyz
In reply to: Baji Shaik (#1)
Re: Three more loops that let a function drop a not-yet-processed index/partition

On Fri, Nov 20, 2026 at 07:00:49PM -0600, Baji Shaik wrote:

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

Yep. I was aware of this one already, just did not get down to look
at how to fix it in more details. At quick glance, that seems
sensible. Thanks for the patch.

CREATE INDEX on
a partitioned table, and ALTER TABLE ... ATTACH PARTITION.

I have not looked at these two.
--
Michael