pg_relation_size / could not open relation with OID # - Mailing list pgsql-general

From tv@fuzzy.cz
Subject pg_relation_size / could not open relation with OID #
Date
Msg-id e5ebb6f285135aebdc53b199aef95be5.squirrel@sq.gransy.com
Whole thread Raw
Responses Re: pg_relation_size / could not open relation with OID #  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hi everyone,

I've run into a strange problem with system catalogs - we're collecting
database stats periodically (every 10 minutes), and from time to time we
get the following error:

--------------------------------------------------
ERROR:  could not open relation with OID 154873708
--------------------------------------------------

Most of the time it works fine - there are about 144 executions every day,
and it fails about twice a day (i.e. about 1%). The OID value is different
every time.

The query executed is this (this one reads table stats, there is a similar
query for indexes and it fails too):

-----------------------------------------------------------------------
SELECT now() AS stat_time, pg_relation_size(stat.relid) AS relation_size,
relfrozenxid AS frozen_xid, age(relfrozenxid) AS frozen_xid_age,
current_database() AS dbname, stat.schemaname AS schemaname, stat.relname
AS tablename, seq_scan, seq_tup_read, idx_scan, idx_tup_fetch,
heap_blks_read, heap_blks_hit, idx_blks_read, idx_blks_hit,
toast_blks_read, toast_blks_hit, tidx_blks_read, tidx_blks_hit, n_tup_ins,
n_tup_upd, n_tup_del, relpages, reltuples, n_tup_hot_upd, n_live_tup,
n_dead_tup, last_vacuum, last_autovacuum, last_analyze, last_autoanalyze
FROM pg_stat_all_tables AS stat LEFT JOIN pg_statio_all_tables AS statio
USING (relid) LEFT JOIN pg_class ON (stat.relid = pg_class.oid)
-----------------------------------------------------------------------

I guess this has something to do with pg_relation_size function, used in
the query. Maybe a race condition or something like that ... Or is that a
know feature?

We've checked if there are any suspicious cron scripts (maintenance with
temporary tables, reindexing etc.) but we have found nothing. Otherwise
the database seems just fine, everything (including backups etc.) works
fine.

The database is running on 8.4.x (not sure which if it's 8.4.4).

regards
Tomas


pgsql-general by date:

Previous
From: Merlin Moncure
Date:
Subject: Re: space taken by NULL values in array
Next
From: Merlin Moncure
Date:
Subject: Re: where does postgres keep the query result until it is returned?