pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedError “cache lookup failed for function”
11+ messages / 4 participants
[nested] [flat]
* Error “cache lookup failed for function”
@ 2020-02-20 18:24 Albrecht Dreß <albrecht.dress@arcor.de>
2020-02-20 18:32 ` Re: Error “cache lookup failed for function” Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 11+ messages in thread
From: Albrecht Dreß @ 2020-02-20 18:24 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Hi all,
On a Debian Buster/64 Bit I run Postgres 11 (apt-cache info):
Package: postgresql-11
Version: 11.7-0+deb10u1
Maintainer: Debian PostgreSQL Maintainers <team+postgresql@tracker.debian.org>
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<-----------------------------------------------
Interestingly, some clients were reporting errors while trying to call a /different/ DB function which had not been touched by the above script.
According to some older reports I found searching the internet for the error, the pg_catalog was probably damaged. As a restart of the daemon didn't help, and following the recommendations in the older reports, I dumped the data (no idea if it was damaged, too, though) and re-installed the cluster form scratch. It now again works as expected using the modified schema.
I would agree that updating the schema of a database server under considerable load is not the best idea, but it should *never* damage the database itself (it would be acceptable if the transaction just fails, though).
Any idea what happened here, i.e. what caused the error, and how I can avoid it?
Thanks in advance,
Albrecht.=
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Error “cache lookup failed for function”
2020-02-20 18:24 Error “cache lookup failed for function” Albrecht Dreß <albrecht.dress@arcor.de>
@ 2020-02-20 18:32 ` Tom Lane <tgl@sss.pgh.pa.us>
2020-02-20 18:57 ` Re: Error “cache lookup failed for function” Tom Lane <tgl@sss.pgh.pa.us>
2020-02-20 19:28 ` Re: Error “cache lookup failed for function” Albrecht Dreß <albrecht.dress@arcor.de>
0 siblings, 2 replies; 11+ messages in thread
From: Tom Lane @ 2020-02-20 18:32 UTC (permalink / raw)
To: Albrecht Dreß <albrecht.dress@arcor.de>; +Cc: pgsql-general@lists.postgresql.org
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
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Error “cache lookup failed for function”
2020-02-20 18:24 Error “cache lookup failed for function” Albrecht Dreß <albrecht.dress@arcor.de>
2020-02-20 18:32 ` Re: Error “cache lookup failed for function” Tom Lane <tgl@sss.pgh.pa.us>
@ 2020-02-20 18:57 ` Tom Lane <tgl@sss.pgh.pa.us>
2020-02-20 19:18 ` Re: Error “cache lookup failed for function” Michael Lewis <mlewis@entrata.com>
1 sibling, 1 reply; 11+ messages in thread
From: Tom Lane @ 2020-02-20 18:57 UTC (permalink / raw)
To: Albrecht Dreß <albrecht.dress@arcor.de>; +Cc: pgsql-general@lists.postgresql.org
I wrote:
> 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.
I reproduced this issue locally (to avoid race conditions, I just had the
function drop itself ;-)) and traced the site of the failure to this
bit in plpgsql function exit:
/*
* Need to look up the expected result type. XXX would be
* better to cache the tupdesc instead of repeating
* get_call_result_type(), but the only easy place to save it
* is in the PLpgSQL_function struct, and that's too
* long-lived: composite types could change during the
* existence of a PLpgSQL_function.
*/
switch (get_call_result_type(fcinfo, &resultTypeId, &tupdesc))
The catalog access inside get_call_result_type is fairly essential,
because this function has OUT parameters, so its pg_proc row is the
ultimate source of truth about what it returns. We could imagine
caching the info earlier during function execution, but as the comment
says, that has its own failure modes ... and they're more important
ones in practice. So I'm afraid there's not much to be done to
improve this.
regards, tom lane
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Error “cache lookup failed for function”
2020-02-20 18:24 Error “cache lookup failed for function” Albrecht Dreß <albrecht.dress@arcor.de>
2020-02-20 18:32 ` Re: Error “cache lookup failed for function” Tom Lane <tgl@sss.pgh.pa.us>
2020-02-20 18:57 ` Re: Error “cache lookup failed for function” Tom Lane <tgl@sss.pgh.pa.us>
@ 2020-02-20 19:18 ` Michael Lewis <mlewis@entrata.com>
0 siblings, 0 replies; 11+ messages in thread
From: Michael Lewis @ 2020-02-20 19:18 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Albrecht Dreß <albrecht.dress@arcor.de>; PostgreSQL General <pgsql-general@lists.postgresql.org>
Given the explicit begin before drop/create, this is a bit of an unexpected
gotcha to have any impact on other transactions. Are there other known
limitations of DDL in a transaction?
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Error “cache lookup failed for function”
2020-02-20 18:24 Error “cache lookup failed for function” Albrecht Dreß <albrecht.dress@arcor.de>
2020-02-20 18:32 ` Re: Error “cache lookup failed for function” Tom Lane <tgl@sss.pgh.pa.us>
@ 2020-02-20 19:28 ` Albrecht Dreß <albrecht.dress@arcor.de>
2020-02-20 19:47 ` Re: Error “cache lookup failed for function” Tom Lane <tgl@sss.pgh.pa.us>
2020-02-20 20:41 ` Re: Error “cache lookup failed for function” Adrian Klaver <adrian.klaver@aklaver.com>
1 sibling, 2 replies; 11+ messages in thread
From: Albrecht Dreß @ 2020-02-20 19:28 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Am 20.02.20 19:32 schrieb(en) Tom Lane:
> 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.
Yes, I agree that this was not a too clever approach…
> 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.
OK, but after fully stopping the daemon via systemctl (which of course disconnects all clients) and re-starting it, the cache is empty, isn't it? So the client after re-connecting /should/ find the proper function? In my case the full restart did *not* help, but produced the same error again afterwards! I didn't reboot the whole box, though.
This led me to the assumption that the database was “somehow” damaged.
Thanks,
Albrecht.=
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Error “cache lookup failed for function”
2020-02-20 18:24 Error “cache lookup failed for function” Albrecht Dreß <albrecht.dress@arcor.de>
2020-02-20 18:32 ` Re: Error “cache lookup failed for function” Tom Lane <tgl@sss.pgh.pa.us>
2020-02-20 19:28 ` Re: Error “cache lookup failed for function” Albrecht Dreß <albrecht.dress@arcor.de>
@ 2020-02-20 19:47 ` Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 11+ messages in thread
From: Tom Lane @ 2020-02-20 19:47 UTC (permalink / raw)
To: Albrecht Dreß <albrecht.dress@arcor.de>; +Cc: pgsql-general@lists.postgresql.org
Albrecht =?iso-8859-1?b?RHJl3w==?= <albrecht.dress@arcor.de> writes:
> OK, but after fully stopping the daemon via systemctl (which of course disconnects all clients) and re-starting it, the cache is empty, isn't it? So the client after re-connecting /should/ find the proper function? In my case the full restart did *not* help, but produced the same error again afterwards! I didn't reboot the whole box, though.
Hm ... that's interesting, but it sounds like you've systematically
expunged all the evidence about what happened :-(
regards, tom lane
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Error “cache lookup failed for function”
2020-02-20 18:24 Error “cache lookup failed for function” Albrecht Dreß <albrecht.dress@arcor.de>
2020-02-20 18:32 ` Re: Error “cache lookup failed for function” Tom Lane <tgl@sss.pgh.pa.us>
2020-02-20 19:28 ` Re: Error “cache lookup failed for function” Albrecht Dreß <albrecht.dress@arcor.de>
@ 2020-02-20 20:41 ` Adrian Klaver <adrian.klaver@aklaver.com>
2020-02-21 17:55 ` Re: Error “cache lookup failed for function” Albrecht Dreß <albrecht.dress@arcor.de>
1 sibling, 1 reply; 11+ messages in thread
From: Adrian Klaver @ 2020-02-20 20:41 UTC (permalink / raw)
To: Albrecht Dreß <albrecht.dress@arcor.de>; pgsql-general@lists.postgresql.org
On 2/20/20 11:28 AM, Albrecht Dreß wrote:
> Am 20.02.20 19:32 schrieb(en) Tom Lane:
>> 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.
>
> Yes, I agree that this was not a too clever approach…
>
>> 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.
>
> OK, but after fully stopping the daemon via systemctl (which of course
> disconnects all clients) and re-starting it, the cache is empty, isn't
> it? So the client after re-connecting /should/ find the proper
> function? In my case the full restart did *not* help, but produced the
> same error again afterwards! I didn't reboot the whole box, though.
It would be nice to know what:
[…]
represented in:
CREATE FUNCTION public.get_result2(mytaskid bigint, OUT data bytea, OUT
metadata jsonb, OUT errortext text, OUT vanished boolean) RETURNS record
[…]
COMMIT;
The Postgres logs during and after restart might provide some info.
Also the errors thrown when accessing the other function.
>
> This led me to the assumption that the database was “somehow” damaged.
>
> Thanks,
> Albrecht.
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Error “cache lookup failed for function”
2020-02-20 18:24 Error “cache lookup failed for function” Albrecht Dreß <albrecht.dress@arcor.de>
2020-02-20 18:32 ` Re: Error “cache lookup failed for function” Tom Lane <tgl@sss.pgh.pa.us>
2020-02-20 19:28 ` Re: Error “cache lookup failed for function” Albrecht Dreß <albrecht.dress@arcor.de>
2020-02-20 20:41 ` Re: Error “cache lookup failed for function” Adrian Klaver <adrian.klaver@aklaver.com>
@ 2020-02-21 17:55 ` Albrecht Dreß <albrecht.dress@arcor.de>
2020-02-21 20:44 ` Re: Error “cache lookup failed for function” Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 1 reply; 11+ messages in thread
From: Albrecht Dreß @ 2020-02-21 17:55 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Am 20.02.20 21:41 schrieb(en) Adrian Klaver:
> It would be nice to know what:
[snip]
> represented in:
Dropping and re-creating the function is actually the last operation in the script. The function is /very/ simple (just a wrapper to hide all internals from "agent" clients):
---8<--------------------------------------------------------------------
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
LANGUAGE plpgsql STABLE SECURITY DEFINER
SET search_path TO 'public', 'pg_temp'
AS $$
BEGIN
SELECT r.data, r.metadata, r.errortext FROM results r INNER JOIN tasks USING(resultid) WHERE taskid = mytaskid LIMIT 1 INTO data, metadata, errortext;
SELECT COUNT(*) = 0 FROM tasks WHERE taskid = mytaskid INTO vanished;
END;
$$;
ALTER FUNCTION public.get_result2(mytaskid bigint, OUT data bytea, OUT metadata jsonb, OUT errortext text, OUT vanished boolean) OWNER TO manager;
REVOKE ALL ON FUNCTION public.get_result2(mytaskid bigint, OUT data bytea, OUT metadata jsonb, OUT errortext text, OUT vanished boolean) FROM PUBLIC;
GRANT ALL ON FUNCTION public.get_result2(mytaskid bigint, OUT data bytea, OUT metadata jsonb, OUT errortext text, OUT vanished boolean) TO "agent";
COMMIT;
---8<--------------------------------------------------------------------
> The Postgres logs during and after restart might provide some info.
>
> Also the errors thrown when accessing the other function.
I attach the (slightly stripped down; I don't want to post ~100k…) log, starting with the very first error at 13:39:59.302 UTC. Prior to that line are *no* errors. I added a few [comments].
At 13:39:59.484 the error message changes, referring to an ancient function “retrieve_single_result()” which (according to the person who wrote the “agent” client) is *not* called. The clients try periodically poll “get_result2()”.
At 13:42:00 the “systemctl restart” has been initiated. At 13:42:02 the database has been stopped and is restarted immediately, revealing one misconfigured client (should be harmless), but the cache lookup error persists.
Thanks in advance for your help,
Albrecht.=
Attachments:
cache_lookup_failed.log (text/x-log, 9.0K) download
[*no* error prior to this line]
2020-02-20 13:39:59.302 UTC [27971] agent@taskdb ERROR: cache lookup failed for function 1821571
2020-02-20 13:39:59.302 UTC [27971] agent@taskdb CONTEXT: PL/pgSQL function get_result2(bigint) while casting return value to function's return type
2020-02-20 13:39:59.302 UTC [27971] agent@taskdb STATEMENT: SELECT data, metadata, errortext, vanished FROM get_result2(26671107)
2020-02-20 13:39:59.302 UTC [28048] agent@taskdb ERROR: cache lookup failed for function 1821571
2020-02-20 13:39:59.302 UTC [28048] agent@taskdb CONTEXT: PL/pgSQL function get_result2(bigint) while casting return value to function's return type
2020-02-20 13:39:59.302 UTC [28048] agent@taskdb STATEMENT: SELECT data, metadata, errortext, vanished FROM get_result2(26670465)
2020-02-20 13:39:59.302 UTC [28021] agent@taskdb ERROR: cache lookup failed for function 1821571
2020-02-20 13:39:59.302 UTC [28021] agent@taskdb CONTEXT: PL/pgSQL function get_result2(bigint) while casting return value to function's return type
2020-02-20 13:39:59.302 UTC [28021] agent@taskdb STATEMENT: SELECT data, metadata, errortext, vanished FROM get_result2(26670465)
[… repeating again and again, with different arguments for the DB function]
2020-02-20 13:39:59.333 UTC [28017] agent@taskdb ERROR: cache lookup failed for function 1821571
2020-02-20 13:39:59.333 UTC [28017] agent@taskdb CONTEXT: PL/pgSQL function get_result2(bigint) while casting return value to function's return type
2020-02-20 13:39:59.333 UTC [28017] agent@taskdb STATEMENT: SELECT data, metadata, errortext, vanished FROM get_result2(26671517)
2020-02-20 13:39:59.335 UTC [27999] agent@taskdb ERROR: cache lookup failed for function 1821571
2020-02-20 13:39:59.335 UTC [27999] agent@taskdb CONTEXT: PL/pgSQL function get_result2(bigint) while casting return value to function's return type
2020-02-20 13:39:59.335 UTC [27999] agent@taskdb STATEMENT: SELECT data, metadata, errortext, vanished FROM get_result2(26671570)
2020-02-20 13:39:59.484 UTC [2504] agent@taskdb ERROR: error result "Error: cache lookup failed for function 1821571
CONTEXT: PL/pgSQL function get_result2(bigint) while casting return value to function's return type
"
2020-02-20 13:39:59.484 UTC [2504] agent@taskdb CONTEXT: PL/pgSQL function retrieve_single_result(bigint) line 7 at RAISE
2020-02-20 13:39:59.484 UTC [2504] agent@taskdb STATEMENT: SELECT data, metadata FROM retrieve_single_result(26619789)
2020-02-20 13:39:59.504 UTC [2504] agent@taskdb ERROR: error result "Error: cache lookup failed for function 1821571
CONTEXT: PL/pgSQL function get_result2(bigint) while casting return value to function's return type
"
2020-02-20 13:39:59.504 UTC [2504] agent@taskdb CONTEXT: PL/pgSQL function retrieve_single_result(bigint) line 7 at RAISE
2020-02-20 13:39:59.504 UTC [2504] agent@taskdb STATEMENT: SELECT data, metadata FROM retrieve_single_result(26618953)
2020-02-20 13:39:59.514 UTC [2504] agent@taskdb ERROR: error result "Error: cache lookup failed for function 1821571
CONTEXT: PL/pgSQL function get_result2(bigint) while casting return value to function's return type
"
2020-02-20 13:39:59.514 UTC [2504] agent@taskdb CONTEXT: PL/pgSQL function retrieve_single_result(bigint) line 7 at RAISE
2020-02-20 13:39:59.514 UTC [2504] agent@taskdb STATEMENT: SELECT data, metadata FROM retrieve_single_result(26483130)
[…repeating again and again, with different arguments for the DB function]
2020-02-20 13:41:45.469 UTC [2504] agent@taskdb ERROR: error result "Error: cache lookup failed for function 1821571
CONTEXT: PL/pgSQL function get_result2(bigint) while casting return value to function's return type
"
2020-02-20 13:41:45.469 UTC [2504] agent@taskdb CONTEXT: PL/pgSQL function retrieve_single_result(bigint) line 7 at RAISE
2020-02-20 13:41:45.469 UTC [2504] agent@taskdb STATEMENT: SELECT data, metadata FROM retrieve_single_result(26619490)
2020-02-20 13:42:00.000 UTC [2036] LOG: cron job 1 starting: SELECT FROM task_watchdog()
2020-02-20 13:42:00.010 UTC [2036] LOG: cron job 1 completed: 1 row
2020-02-20 13:42:00.404 UTC [2027] LOG: received fast shutdown request
2020-02-20 13:42:00.404 UTC [2027] LOG: aborting any active transactions
2020-02-20 13:42:00.405 UTC [28051] agent@taskdb FATAL: terminating connection due to administrator command
2020-02-20 13:42:00.405 UTC [28055] agent@taskdb FATAL: terminating connection due to administrator command
[…many more clients being disconnected…]
2020-02-20 13:42:00.407 UTC [28036] agent@taskdb FATAL: terminating connection due to administrator command
2020-02-20 13:42:00.407 UTC [7065] agent@taskdb FATAL: terminating connection due to administrator command
2020-02-20 13:42:00.407 UTC [2036] LOG: pg_cron scheduler shutting down
2020-02-20 13:42:00.407 UTC [28042] agent@taskdb FATAL: terminating connection due to administrator command
2020-02-20 13:42:00.408 UTC [27987] agent@taskdb FATAL: terminating connection due to administrator command
[…still disconnecting clients…]
2020-02-20 13:42:00.433 UTC [20299] agent@taskdb FATAL: terminating connection due to administrator command
2020-02-20 13:42:00.434 UTC [20296] agent@taskdb FATAL: terminating connection due to administrator command
[…]
2020-02-20 13:42:00.713 UTC [1895] agent@taskdb FATAL: the database system is shutting down
2020-02-20 13:42:00.717 UTC [1896] agent@taskdb FATAL: the database system is shutting down
2020-02-20 13:42:00.725 UTC [1897] agent@taskdb FATAL: the database system is shutting down
[…and many more of these…]
2020-02-20 13:42:00.729 UTC [1923] agent@taskdb FATAL: the database system is shutting down
2020-02-20 13:42:00.738 UTC [1928] agent@taskdb FATAL: the database system is shutting down
2020-02-20 13:42:00.742 UTC [2027] LOG: background worker "logical replication launcher" (PID 2037) exited with exit code 1
2020-02-20 13:42:00.745 UTC [1902] agent@taskdb FATAL: the database system is shutting down
2020-02-20 13:42:00.747 UTC [1900] agent@taskdb FATAL: the database system is shutting down
[…]
2020-02-20 13:42:01.489 UTC [1958] agent@taskdb FATAL: the database system is shutting down
2020-02-20 13:42:01.491 UTC [1956] agent@taskdb FATAL: the database system is shutting down
2020-02-20 13:42:01.494 UTC [2031] LOG: shutting down
2020-02-20 13:42:01.497 UTC [1957] agent@taskdb FATAL: the database system is shutting down
2020-02-20 13:42:01.498 UTC [1955] agent@taskdb FATAL: the database system is shutting down
[…]
2020-02-20 13:42:01.766 UTC [1988] agent@taskdb FATAL: the database system is shutting down
2020-02-20 13:42:01.940 UTC [1989] agent@taskdb FATAL: the database system is shutting down
2020-02-20 13:42:01.986 UTC [2027] LOG: database system is shut down
[as I initiated s 'systemctl restart', the system is started immediately]
2020-02-20 13:42:02.214 UTC [1995] LOG: listening on IPv4 address "0.0.0.0", port 5432
2020-02-20 13:42:02.214 UTC [1995] LOG: listening on IPv6 address "::", port 5432
2020-02-20 13:42:02.215 UTC [1995] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2020-02-20 13:42:02.243 UTC [1996] LOG: database system was shut down at 2020-02-20 13:42:01 UTC
2020-02-20 13:42:02.265 UTC [1995] LOG: database system is ready to accept connections
2020-02-20 13:42:02.284 UTC [1997] agent@taskdb FATAL: the database system is starting up
2020-02-20 13:42:02.287 UTC [2005] agent@taskdb FATAL: no pg_hba.conf entry for host "172.16.98.8", user "agent", database "taskdb", SSL off
[misconfigured client, the message is ok]
2020-02-20 13:42:02.292 UTC [2003] LOG: pg_cron scheduler started
2020-02-20 13:42:02.782 UTC [2012] [unknown]@[unknown] LOG: incomplete startup packet
2020-02-20 13:42:20.350 UTC [2133] agent@taskdb ERROR: error result "Error: cache lookup failed for function 1821571
CONTEXT: PL/pgSQL function get_result2(bigint) while casting return value to function's return type
"
2020-02-20 13:42:20.350 UTC [2133] agent@taskdb CONTEXT: PL/pgSQL function retrieve_single_result(bigint) line 7 at RAISE
2020-02-20 13:42:20.350 UTC [2133] agent@taskdb STATEMENT: SELECT data, metadata FROM retrieve_single_result(26619789)
2020-02-20 13:42:20.374 UTC [2133] agent@taskdb ERROR: error result "Error: cache lookup failed for function 1821571
CONTEXT: PL/pgSQL function get_result2(bigint) while casting return value to function's return type
"
2020-02-20 13:42:20.374 UTC [2133] agent@taskdb CONTEXT: PL/pgSQL function retrieve_single_result(bigint) line 7 at RAISE
2020-02-20 13:42:20.374 UTC [2133] agent@taskdb STATEMENT: SELECT data, metadata FROM retrieve_single_result(26618953)
2020-02-20 13:42:20.388 UTC [2133] agent@taskdb ERROR: error result "Error: cache lookup failed for function 1821571
CONTEXT: PL/pgSQL function get_result2(bigint) while casting return value to function's return type
"
2020-02-20 13:42:20.388 UTC [2133] agent@taskdb CONTEXT: PL/pgSQL function retrieve_single_result(bigint) line 7 at RAISE
2020-02-20 13:42:20.388 UTC [2133] agent@taskdb STATEMENT: SELECT data, metadata FROM retrieve_single_result(26483130)
[…continues with the same error again and again]
=
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Error “cache lookup failed for function”
2020-02-20 18:24 Error “cache lookup failed for function” Albrecht Dreß <albrecht.dress@arcor.de>
2020-02-20 18:32 ` Re: Error “cache lookup failed for function” Tom Lane <tgl@sss.pgh.pa.us>
2020-02-20 19:28 ` Re: Error “cache lookup failed for function” Albrecht Dreß <albrecht.dress@arcor.de>
2020-02-20 20:41 ` Re: Error “cache lookup failed for function” Adrian Klaver <adrian.klaver@aklaver.com>
2020-02-21 17:55 ` Re: Error “cache lookup failed for function” Albrecht Dreß <albrecht.dress@arcor.de>
@ 2020-02-21 20:44 ` Adrian Klaver <adrian.klaver@aklaver.com>
2020-02-26 19:37 ` Re: Error “cache lookup failed for function” Albrecht Dreß <albrecht.dress@arcor.de>
0 siblings, 1 reply; 11+ messages in thread
From: Adrian Klaver @ 2020-02-21 20:44 UTC (permalink / raw)
To: Albrecht Dreß <albrecht.dress@arcor.de>; pgsql-general@lists.postgresql.org
On 2/21/20 9:55 AM, Albrecht Dreß wrote:
> Am 20.02.20 21:41 schrieb(en) Adrian Klaver:
>> It would be nice to know what:
> [snip]
>> represented in:
>
> Dropping and re-creating the function is actually the last operation in
> the script. The function is /very/ simple (just a wrapper to hide all
> internals from "agent" clients):
>
> ---8<--------------------------------------------------------------------
> 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
> LANGUAGE plpgsql STABLE SECURITY DEFINER
> SET search_path TO 'public', 'pg_temp'
> AS $$
> BEGIN
> SELECT r.data, r.metadata, r.errortext FROM results r INNER JOIN
> tasks USING(resultid) WHERE taskid = mytaskid LIMIT 1 INTO data,
> metadata, errortext;
> SELECT COUNT(*) = 0 FROM tasks WHERE taskid = mytaskid INTO vanished;
> END;
> $$;
> ALTER FUNCTION public.get_result2(mytaskid bigint, OUT data bytea, OUT
> metadata jsonb, OUT errortext text, OUT vanished boolean) OWNER TO manager;
> REVOKE ALL ON FUNCTION public.get_result2(mytaskid bigint, OUT data
> bytea, OUT metadata jsonb, OUT errortext text, OUT vanished boolean)
> FROM PUBLIC;
> GRANT ALL ON FUNCTION public.get_result2(mytaskid bigint, OUT data
> bytea, OUT metadata jsonb, OUT errortext text, OUT vanished boolean) TO
> "agent";
> COMMIT;
> ---8<--------------------------------------------------------------------
>
>> The Postgres logs during and after restart might provide some info.
>>
>> Also the errors thrown when accessing the other function.
>
> I attach the (slightly stripped down; I don't want to post ~100k…) log,
> starting with the very first error at 13:39:59.302 UTC. Prior to that
> line are *no* errors. I added a few [comments].
>
> At 13:39:59.484 the error message changes, referring to an ancient
> function “retrieve_single_result()” which (according to the person who
> wrote the “agent” client) is *not* called. The clients try periodically
> poll “get_result2()”.
>
> At 13:42:00 the “systemctl restart” has been initiated. At 13:42:02 the
> database has been stopped and is restarted immediately, revealing one
> misconfigured client (should be harmless), but the cache lookup error
> persists.
Hmm. More questions:
1) From your original post what does the below mean?:
-- add several db functions
-- replace a DB function:
2) What do you see when you do?:
select * from pg_proc where oid = 1821571;
3) What is the definition for retrieve_single_result()?
4) What does the below show?:
select proname, prosrc from pg_proc where proname in
('retrieve_single_result', 'get_result2');
>
> Thanks in advance for your help,
> Albrecht.
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Error “cache lookup failed for function”
2020-02-20 18:24 Error “cache lookup failed for function” Albrecht Dreß <albrecht.dress@arcor.de>
2020-02-20 18:32 ` Re: Error “cache lookup failed for function” Tom Lane <tgl@sss.pgh.pa.us>
2020-02-20 19:28 ` Re: Error “cache lookup failed for function” Albrecht Dreß <albrecht.dress@arcor.de>
2020-02-20 20:41 ` Re: Error “cache lookup failed for function” Adrian Klaver <adrian.klaver@aklaver.com>
2020-02-21 17:55 ` Re: Error “cache lookup failed for function” Albrecht Dreß <albrecht.dress@arcor.de>
2020-02-21 20:44 ` Re: Error “cache lookup failed for function” Adrian Klaver <adrian.klaver@aklaver.com>
@ 2020-02-26 19:37 ` Albrecht Dreß <albrecht.dress@arcor.de>
2020-02-27 15:52 ` Re: Error “cache lookup failed for function” Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 1 reply; 11+ messages in thread
From: Albrecht Dreß @ 2020-02-26 19:37 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Sorry for the late reply, I've been on a short vacation…
Am 21.02.20 21:44 schrieb(en) Adrian Klaver:
> 1) From your original post what does the below mean?:
>
> -- add several db functions
One trigger function, plus two “normal” ones, all (yet) unused.
> -- replace a DB function:
This was the
---8<--------------------------------------------------------------------
DROP FUNCTION public.get_result2[…]
CREATE FUNCTION public.get_result2[…]
---8<--------------------------------------------------------------------
sequence triggering the error.
> 2) What do you see when you do?:
>
> select * from pg_proc where oid = 1821571;
Unfortunately, when I saw that restarting the cluster didn't solve the issue, I re-installed it from a dump (which appears to be intact, btw), but /without/ taking a copy of the original data folder. Thus, this information is lost, sorry.
> 3) What is the definition for retrieve_single_result()?
Ancient implementation, somewhat similar to get_result2(), but with less security and different error checking approach:
---8<--------------------------------------------------------------------
CREATE FUNCTION public.retrieve_single_result(mytaskid bigint, OUT data bytea, OUT metadata jsonb) RETURNS record
LANGUAGE plpgsql STABLE SECURITY DEFINER
AS $$
DECLARE
errortext text;
BEGIN
SELECT results.data, results.metadata, results.errortext FROM results LEFT JOIN tasks ON tasks.resultid = results.resultid WHERE taskid = mytaskid LIMIT 1 INTO data, metadata, errortext;
IF errortext IS NOT NULL THEN
RAISE EXCEPTION 'error result "%"', errortext;
END IF;
END;
$$;
---8<--------------------------------------------------------------------
> 4) What does the below show?:
>
> select proname, prosrc from pg_proc where proname in ('retrieve_single_result', 'get_result2');
Same problem as with #2, sorry…
Thanks,
Albrecht.=
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Error “cache lookup failed for function”
2020-02-20 18:24 Error “cache lookup failed for function” Albrecht Dreß <albrecht.dress@arcor.de>
2020-02-20 18:32 ` Re: Error “cache lookup failed for function” Tom Lane <tgl@sss.pgh.pa.us>
2020-02-20 19:28 ` Re: Error “cache lookup failed for function” Albrecht Dreß <albrecht.dress@arcor.de>
2020-02-20 20:41 ` Re: Error “cache lookup failed for function” Adrian Klaver <adrian.klaver@aklaver.com>
2020-02-21 17:55 ` Re: Error “cache lookup failed for function” Albrecht Dreß <albrecht.dress@arcor.de>
2020-02-21 20:44 ` Re: Error “cache lookup failed for function” Adrian Klaver <adrian.klaver@aklaver.com>
2020-02-26 19:37 ` Re: Error “cache lookup failed for function” Albrecht Dreß <albrecht.dress@arcor.de>
@ 2020-02-27 15:52 ` Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 0 replies; 11+ messages in thread
From: Adrian Klaver @ 2020-02-27 15:52 UTC (permalink / raw)
To: Albrecht Dreß <albrecht.dress@arcor.de>; pgsql-general@lists.postgresql.org
On 2/26/20 11:37 AM, Albrecht Dreß wrote:
> Sorry for the late reply, I've been on a short vacation…
>
> Am 21.02.20 21:44 schrieb(en) Adrian Klaver:
>> 1) From your original post what does the below mean?:
>>
>> -- add several db functions
>
> One trigger function, plus two “normal” ones, all (yet) unused.
>
>> -- replace a DB function:
>
> This was the
>
> ---8<--------------------------------------------------------------------
> DROP FUNCTION public.get_result2[…]
> CREATE FUNCTION public.get_result2[…]
> ---8<--------------------------------------------------------------------
>
> sequence triggering the error.
>
>> 2) What do you see when you do?:
>>
>> select * from pg_proc where oid = 1821571;
>
> Unfortunately, when I saw that restarting the cluster didn't solve the
> issue, I re-installed it from a dump (which appears to be intact, btw),
> but /without/ taking a copy of the original data folder. Thus, this
> information is lost, sorry.
>
>> 3) What is the definition for retrieve_single_result()?
>
> Ancient implementation, somewhat similar to get_result2(), but with less
> security and different error checking approach:
>
> ---8<--------------------------------------------------------------------
> CREATE FUNCTION public.retrieve_single_result(mytaskid bigint, OUT data
> bytea, OUT metadata jsonb) RETURNS record
> LANGUAGE plpgsql STABLE SECURITY DEFINER
> AS $$
> DECLARE
> errortext text;
> BEGIN
> SELECT results.data, results.metadata, results.errortext FROM
> results LEFT JOIN tasks ON tasks.resultid = results.resultid WHERE
> taskid = mytaskid LIMIT 1 INTO data, metadata, errortext;
> IF errortext IS NOT NULL THEN
> RAISE EXCEPTION 'error result "%"', errortext;
> END IF;
> END;
> $$;
> ---8<--------------------------------------------------------------------
>
>> 4) What does the below show?:
>>
>> select proname, prosrc from pg_proc where proname in
>> ('retrieve_single_result', 'get_result2');
>
> Same problem as with #2, sorry…
Alright, as Tom said upstream, there is not much that can be done with
information missing. Hopefully it does not happen again, but if it does
you know what needs to be captured.
>
> Thanks,
> Albrecht.
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 11+ messages in thread
end of thread, other threads:[~2020-02-27 15:52 UTC | newest]
Thread overview: 11+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-02-20 18:24 Error “cache lookup failed for function” Albrecht Dreß <albrecht.dress@arcor.de>
2020-02-20 18:32 ` Tom Lane <tgl@sss.pgh.pa.us>
2020-02-20 18:57 ` Tom Lane <tgl@sss.pgh.pa.us>
2020-02-20 19:18 ` Michael Lewis <mlewis@entrata.com>
2020-02-20 19:28 ` Albrecht Dreß <albrecht.dress@arcor.de>
2020-02-20 19:47 ` Tom Lane <tgl@sss.pgh.pa.us>
2020-02-20 20:41 ` Adrian Klaver <adrian.klaver@aklaver.com>
2020-02-21 17:55 ` Albrecht Dreß <albrecht.dress@arcor.de>
2020-02-21 20:44 ` Adrian Klaver <adrian.klaver@aklaver.com>
2020-02-26 19:37 ` Albrecht Dreß <albrecht.dress@arcor.de>
2020-02-27 15:52 ` Adrian Klaver <adrian.klaver@aklaver.com>
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