Re: ERROR: could not open relation with OID XXXX - Mailing list pgsql-general

From Marcelo Zabani
Subject Re: ERROR: could not open relation with OID XXXX
Date
Msg-id CACgY3QZ36_4r6qm0SASjSaW01zjEwQKB8yvwSHQ+nGthuOerFw@mail.gmail.com
Whole thread Raw
In response to Re: ERROR: could not open relation with OID XXXX  (Ron Johnson <ronljohnsonjr@gmail.com>)
List pgsql-general
> What version (including minor number)?

On my computer I can reproduce the error with v16.1. At my job I know it's v15 but I can't access it right now so don't know the minor version. In any case, at my job it's much bigger queries we run; I'll elaborate why below.

> Just out of curiosity, WHY do you do this?  It's never occurred to me to do that; maybe it's something useful that I've been overlooking.

A project developed by me, codd - https://github.com/mzabani/codd - applies postgresql migrations and checks tables, columns names/order/types, indexes, etc. ("the full schema") to ensure databases in every environment match what developers have on their computers. This is why the queries are bigger, e.g. https://github.com/mzabani/codd/blob/master/src/Codd/Representations/Database/Pg12.hs#L523-L540

One yet untested hypothesis is that codd is picking up temporary tables when we deploy that are soon destroyed by the application, and that maybe postgres is running into this error because it executes some of these functions _before_ filtering out temporary relations (WHERE relpersistence <> 't'). This might be possible depending on query plan, I believe. But again, an untested hypothesis.

On Sun, Aug 25, 2024 at 11:31 AM Ron Johnson <ronljohnsonjr@gmail.com> wrote:
On Sun, Aug 25, 2024 at 9:42 AM Marcelo Zabani <mzabani@gmail.com> wrote:
Hi all,

I can reproduce the error in the subject from time to time when querying catalog tables while DDL is happening concurrently. Here's a bash script that reproduces it (not always, you might have to run it many times until you see ERROR:  could not open relation with OID XXXX):
[snip] 
I've seen this happen in Production without pg_sleep in the mix, too. I added pg_sleep to the example above only because it makes the error easier to reproduce.

What version (including minor number)?
 
Is there something I can do to avoid this? Is my understanding of how the catalog tables work wrong?

Just out of curiosity, WHY do you do this?  It's never occurred to me to do that; maybe it's something useful that I've been overlooking.

--
Death to America, and butter sauce.
Iraq lobster!

pgsql-general by date:

Previous
From: Ron Johnson
Date:
Subject: Re: ERROR: could not open relation with OID XXXX
Next
From: Tomas Vondra
Date:
Subject: Re: ERROR: could not open relation with OID XXXX