From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: pgsql-bugs@postgresql.org
Cc: brian.johnson@emolhealth.com
Cc: aaron.thul@emolhealth.com
Subject: 9.4 and reproducible "ERROR: could not read block 0 in file..."
Date: Tue, 30 Dec 2014 18:42:00 +0000
Message-ID: <87tx0dc80x.fsf@news-spur.riddles.org.uk> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Looked into this based on a report via IRC, and constructed the
following minimal test case. The original reporter found it in an
attempt to migrate to 9.4 from an earlier version.
(Yes, I know the function is behaving badly in that it is declared
immutable while nevertheless accessing the table. I'm sure this is
related to the problem, but (a) it presumably worked before, for
sufficient values of "worked", and (b) if it's going to be disallowed,
I think it needs to fail more cleanly than this.)
create table ftst (id integer, v text);
create function actual_v(integer) returns text
language plpgsql immutable
as $f$
declare
res text;
begin
select v into res from ftst f where f.id=$1;
return res;
end;
$f$;
insert into ftst select i, 'value '||i from generate_series(1,60) i;
create index on ftst (id);
create index on ftst (actual_v(id));
ERROR: could not read block 0 in file "base/12135/16419": read only 0 of 8192 bytes
CONTEXT: SQL statement "select v from ftst f where f.id=$1"
PL/pgSQL function actual_v(integer) line 1 at SQL statement
select * from ftst;
ERROR: could not open relation with OID 16419
(note that no file base/12135/16419 exists at this point)
This looks to me like a catalog caching issue (the "could not open"
error goes away if you reconnect the client), but I've not yet found
exactly what's going on in the code. Hypothesis: the query in the
function is trying to access the index which is being created? The
cache entry for that index isn't cleaned up when the index creation
fails?
(Possibly relevant: if you don't create the (id) index first, the
error does not occur; effect of relhasindex not being set true yet?)
--
Andrew (irc:RhodiumToad)
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: andrew@tao11.riddles.org.uk, brian.johnson@emolhealth.com, aaron.thul@emolhealth.com
Subject: Re: 9.4 and reproducible "ERROR: could not read block 0 in file..."
In-Reply-To: <87tx0dc80x.fsf@news-spur.riddles.org.uk>
References: <87tx0dc80x.fsf@news-spur.riddles.org.uk>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox