Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1siFZC-001BBp-HD for pgsql-general@arkaria.postgresql.org; Sun, 25 Aug 2024 15:54:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1siFZA-00GTfW-Cs for pgsql-general@arkaria.postgresql.org; Sun, 25 Aug 2024 15:54:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1siFZ9-00GTfN-P5 for pgsql-general@lists.postgresql.org; Sun, 25 Aug 2024 15:54:08 +0000 Received: from relay7-d.mail.gandi.net ([217.70.183.200]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1siFZ2-001Nld-VJ for pgsql-general@lists.postgresql.org; Sun, 25 Aug 2024 15:54:06 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 93CA220002; Sun, 25 Aug 2024 15:53:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vondra.me; s=gm1; t=1724601238; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BqnNyDeO3MSp6R4YUWOXV6e3kpqjWaW4L+8K4DmpgdI=; b=WPYE8KcNKi/salr8f1MSCjySkEemhG+3OXWsUXbAqfZkTil8XKWXr4UEWUrV9o/Ab/mjw8 UnskYwARPKdgpIPWbkrid9NJfTIzvnzTYrfiZLyg/qNxn/06KwGFBdLISSGxsbtVLaj648 aUqOMEA9fRPNtYf1T7HPptzcsEUi5XkA8bwg92Yo6pZLQ3m6ybJrA4+yy1ynq3UqJy8/Pp KRD7yOVAjBjcAVohirOQ2cukPWluUkEANoXSHVXnK6pMflzANyPqwZmn7Vo6J0PTON3Us3 QKmYu54yajcr4CDI4j4YH/biPAHbSstULXsjI6Ga4W/NXfZ3LmBGTcQrf2uCrQ== Message-ID: <6481440a-d974-4e35-b2a5-79a13c4b79d2@vondra.me> Date: Sun, 25 Aug 2024 17:53:56 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: ERROR: could not open relation with OID XXXX To: Marcelo Zabani Cc: pgsql-general@lists.postgresql.org References: <73bc7752-442c-4c67-a263-46017f1948cc@vondra.me> Content-Language: en-US From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-GND-Sasl: tomas@vondra.me List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 8/25/24 17:36, Marcelo Zabani wrote: >> we do some special stuff for catalogs > > That is good to know, thanks! > >> I believe you could actually lock the pg_class rows for update. Just > add FOR UPDATE at the end of the query. > > Thanks, but I tried that and got "ERROR:  permission denied for table > pg_class", even if I try it only for tables the user owns. > Yeah, I tried that with a superuser, I didn't realize it'd fail for regular users who don't have rights to modify pg_class directly. > At least considering the use-case of avoiding this error due to > temporary tables/indexes (which are a part of normal application > execution), I was thinking of using materialized CTEs that filters those > out, and only after that using other functions that for example take > OIDs and return definitions. Other kinds of DDL that create > non-temporary tables can be "blamed" on developers in my case. > Do you think using those materialized CTEs could help? And do you think > this can be considered a bug that I should report or is it just too > edge-casey to consider? I have no idea what you mean - what would be filtered out, etc. But you can give it a try - you have a reproducer, so testing if it fails should not be that difficult. Other than that, I think you can do two things: 1) Make the application to simply retry in it sees this error. 2) Lock the objects using LOCK TABLE before running the query. regards -- Tomas Vondra