Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 26CB9B5DC3F for ; Wed, 13 Jul 2011 20:32:37 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 27485-09 for ; Wed, 13 Jul 2011 23:32:31 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id CF236B5DC3E for ; Wed, 13 Jul 2011 20:32:30 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p6DNWLqK012792; Wed, 13 Jul 2011 19:32:21 -0400 (EDT) To: Steve Crawford cc: "pgsql-admin@postgresql.org Admin" Subject: Re: could not open relation with OID In-reply-to: <4E1E1CFE.2030500@pinpointresearch.com> References: <4E1E1CFE.2030500@pinpointresearch.com> Comments: In-reply-to Steve Crawford message dated "Wed, 13 Jul 2011 15:32:30 -0700" Date: Wed, 13 Jul 2011 19:32:21 -0400 Message-ID: <12791.1310599941@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201107/96 X-Sequence-Number: 37875 Steve Crawford writes: > I've seen the "could not open relation with OID" error a couple times > recently and Googling for that error gives responses ranging from *very > scary* to fuggetaboutit. > The error today occurred running this query which is part of a database > status reporting script: > select > pg_size_pretty(sum(pg_relation_size(oid))::bigint) as "Database > Table Size" > from > pg_class > where > relkind = 'r' > ; > could not open relation with OID 81285213 > Pre-answering some potential questions based on threads I read: > - There are lots of scripts and processes that use temporary tables > Worry or not worry? Not worry. This is expected when you run a query like that against a database where tables are concurrently getting dropped. In essence, the failure occurs when a table got dropped between the time the query saw its entry in pg_class and when pg_relation_size gets called. It's difficult to avoid this without introducing painful amounts of locking, though at times we've debated having pg_relation_size silently return NULL if the OID can't be found. (The main objection is that this would obscure actual mistakes, like passing something other than relation OIDs.) You might be able to dodge the problem by excluding temp relations from the reporting query, though whether the sum of only non-temp rel sizes is of value to you is hard to guess from here. regards, tom lane