From: Tom Lane <tgl@sss.pgh.pa.us>
To: Albrecht Dreß <albrecht.dress@arcor.de>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Error “cache lookup failed for function”
Date: Thu, 20 Feb 2020 13:32:53 -0500
Message-ID: <16784.1582223573@sss.pgh.pa.us> (raw)
In-Reply-To: <NX26BD7O.SQ6NCQDL.Z4KK4FBY@HXCHZXMY.EBBFSJQH.OUMOBSJN>
References: <NX26BD7O.SQ6NCQDL.Z4KK4FBY@HXCHZXMY.EBBFSJQH.OUMOBSJN>
Albrecht =?iso-8859-1?b?RHJl3w==?= <albrecht.dress@arcor.de> writes:
> I tried to update the running server by executing the following SQL update script using psql:
> ---8<-----------------------------------------------
> BEGIN;
> -- add a column to an existing table
> -- add a new table
> -- add several db functions
> -- replace a DB function:
> DROP FUNCTION public.get_result2(mytaskid bigint, OUT data bytea, OUT metadata jsonb, OUT errortext text, OUT vanished boolean);
> CREATE FUNCTION public.get_result2(mytaskid bigint, OUT data bytea, OUT metadata jsonb, OUT errortext text, OUT vanished boolean) RETURNS record
> […]
> COMMIT;
> ---8<-----------------------------------------------
> About ~350 clients were connected to the server when I ran the above script, a few of them using, inter alia, the function get_result2() which ought to be replaced.
> Immediately after running the script, the log was filled with errors
> ---8<-----------------------------------------------
> ERROR: cache lookup failed for function 1821571
> CONTEXT: PL/pgSQL function get_result2(bigint) while casting return value to function's return type
> STATEMENT: SELECT data, metadata, errortext, vanished FROM get_result2(26671107)
> ---8<-----------------------------------------------
This is, actually, not very surprising. You dropped the old function
while clients were using it. The new function is a completely unrelated
object, even if it happens to have the same name.
What you should have done was CREATE OR REPLACE FUNCTION, which would
have preserved the object's identity.
It does seem a bit annoying that something in plpgsql is apparently
doing a fresh catalog lookup to find information that likely was
already cached at the start of function execution. But I think that's
a performance deficiency, not a bug per se.
regards, tom lane
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-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, albrecht.dress@arcor.de
Subject: Re: Error “cache lookup failed for function”
In-Reply-To: <16784.1582223573@sss.pgh.pa.us>
References: <NX26BD7O.SQ6NCQDL.Z4KK4FBY@HXCHZXMY.EBBFSJQH.OUMOBSJN> <16784.1582223573@sss.pgh.pa.us>
* 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