You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.06 13:12:02