PostgreSQL 11 触发cache lookup failed for type错误问题求助
PostgreSQL 11 偶发cache lookup failed for type问题排查求助
- 运行环境:多台不同版本RHEL 7.x服务器,所有PostgreSQL实例版本均为11
- 问题现象:约半数实例偶发
cache lookup failed for type错误,问题发生概率与RHEL版本无明确关联
测试用例
drop table if exists test1; drop table if exists test2; drop trigger if exists test1_tr on test1; drop function if exists tf_test1; create table test1 (name varchar(8) not null); create table test2 (name varchar(8) not null); \echo create trigger function tf_test1 CREATE OR REPLACE FUNCTION tf_test1() RETURNS trigger AS $BODY$ BEGIN IF TG_OP = 'INSERT' THEN INSERT INTO test2(name) VALUES (NEW.name); END IF; return new; END $BODY$ LANGUAGE 'plpgsql'; \echo create trigger test1_tr CREATE TRIGGER test1_tr AFTER INSERT OR UPDATE OR DELETE ON test1 FOR EACH ROW EXECUTE PROCEDURE tf_test1(); \echo Insert insert into test1 (name) values ('NAME_001'); insert into test1 (name) values ('NAME_002'); insert into test1 (name) values ('NAME_003'); insert into test1 (name) values ('NAME_004'); \echo Select test1 select * from test1; \echo Select test2 select * from test2;
执行输出结果
DROP TABLE DROP TABLE DROP TABLE DROP TABLE DROP TRIGGER DROP FUNCTION CREATE TABLE CREATE TABLE create trigger function tf_test1 CREATE FUNCTION create trigger test1_tr CREATE TRIGGER Insert INSERT 0 1 psql:test3.sql:28: ERROR: cache lookup failed for type 113 CONTEXT: SQL statement "INSERT INTO test2(name) VALUES (NEW.name)" PL/pgSQL function tf_test1() line 4 at SQL statement INSERT 0 1 INSERT 0 1 Select test1 name ---------- NAME_001 NAME_003 NAME_004 (3 rows) Select test2 name ---------- NAME_001 NAME_003 NAME_004 (3 rows)
已排查情况与求助
我已查询pg_class、pg_type系统表,均未找到报错中提到的OID为113的类型记录。我是资深Oracle DBA,刚接触PostgreSQL不久,初步判断这属于PostgreSQL内部错误而非代码问题,但全网搜索相关资料较少,恳请各位帮忙分析问题原因,提供解决思路,感谢。
内容的提问来源于stack exchange,提问作者Joseph Gohlke
相关产品推荐
相关产品推荐

