Re: ERROR: could not open relation with OID XXXX

From: Marcelo Zabani <mzabani(at)gmail(dot)com>
To: Ron Johnson <ronljohnsonjr(at)gmail(dot)com>
Cc: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: ERROR: could not open relation with OID XXXX
Date: 2024-08-25 15:05:22
Message-ID: CACgY3QZ36_4r6qm0SASjSaW01zjEwQKB8yvwSHQ+nGthuOerFw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)gmail(dot)com>
wrote:

> On Sun, Aug 25, 2024 at 9:42 AM Marcelo Zabani <mzabani(at)gmail(dot)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!
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tomas Vondra 2024-08-25 15:06:46 Re: ERROR: could not open relation with OID XXXX
Previous Message Ron Johnson 2024-08-25 14:31:02 Re: ERROR: could not open relation with OID XXXX