I have created a PostgreSQL cluster with 3 nodes using Patroni.
I am using Ubuntu 18.04, Postgresql-10 and Timescaledb 1.4.2.
In postgresql.conf file I have included shared_preload_libraries = 'timescaledb'
When extend the postresql with timescaledb using the command
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
it gives the error
ERROR: cache lookup failed for function 1
So, to summarize our discussion on Slack, this is what was the issue. I'm summarizing it here since it can be useful to others that run into a similar problem.
TD;DR. You had problems with all extensions on this machine, not only TimescaleDB, and the problem turned out to be related to creating new C functions which the extension was doing.
When functions are defined, PostgreSQL takes the part after
LANGUAGE(in this caseC) and look for a language validator inpg_languages. The code for this is inCreateFunctionin the filefunctioncmds.c.In your case
pg_languagescontained:From the table above, OID for the language validator (which is our culprit) is 1.
Once that is done, PostgreSQL will call the validator with the function to be defined and allow the validator to check that the function is correctly defined. This is done in
ProcedureCreatein the filepg_proc.c.It proceeds by looking up the OID of the function in the
pg_proctable, which in your case contained:So, no procedure for the language validator is found and it generates the error here (this is inside
fmgr_info_cxt_securityinfmgr.c):It is possible to fix this by looking up the correct language validator to use. All the built-in validators are named
fmgr_<lang>_validatorso we can find them using:So, this query will update the
lanvalidatorcolumn to use the right validator.Note that this explains why you get the error, but not why
pg_languagescontained the wrong OID for thelanvalidatorcolumn. We hypothesized that it could something that happened during a failover since you had a few promotions happen, but ultimately, it is pure guessing.