PostgreSQL cache lookup failed for type XXXX 錯誤
文前說明
作為碼農中的一員,需要不斷的學習,我工作之餘將一些分析總結和學習筆記寫成部落格與大家一起交流,也希望採用這種方式記錄自己的學習之旅。
本文僅供學習交流使用,侵權必刪。
不用於商業目的,轉載請註明出處。
錯誤資訊
- 執行 pg_dump 命令備份,提示 cache lookup failed for type... 錯誤。
2018-03-08 00:19:14 4285: Start of engine-backup mode backup scope all file /root/ovirt-engine.bak
2018-03-08 00:19:14 4285: Backing up:
2018-03-08 00:19:14 4285: Generating pgpass
2018-03-08 00:19:15 4285: Creating temp folder /tmp/engine-backup.Z8RvsbYGGl/tar
2018-03-08 00:19:15 4285: - Files
2018-03-08 00:19:15 4285: Backing up files to /tmp/engine-backup.Z8RvsbYGGl/tar/files
2018-03-08 00:19:15 4285: - Engine database 'engine'
2018-03-08 00:19:15 4285: Backing up database to /tmp/engine-backup.Z8RvsbYGGl/tar/db/engine_backup.db
pg_dump: SQL command failed
pg_dump: Error message from server: ERROR: cache lookup failed for type 222222
pg_dump: The command was: SELECT proretset, prosrc, probin, pg_catalog.pg_get_function_arguments(oid) AS funcargs, pg_catalog.pg_get_function_identity_arguments(oid) AS funciargs, pg_catalog.pg_get_function_result(oid) AS funcresult, proiswindow, provolatile, proisstrict, prosecdef, proconfig, procost, prorows, (SELECT lanname FROM pg_catalog.pg_language WHERE oid = prolang) AS lanname FROM pg_catalog.pg_proc WHERE oid = '237534'::pg_catalog.oid
2018-03-08 00:19:16 4285: FATAL: Database engine backup failed
錯誤分析
- 根據提示資訊上網查詢資料,大概瞭解了錯誤原因。參考資料如下。
- https://www.postgresql.org/message-id/AANLkTik0Nfyw%2B1QV7nD5z6GtkrF92w9AvitHYfgibTJb@mail.gmail.com
- http://www.postgresql-archive.org/Cache-lookup-failure-for-index-during-pg-dump-td2125326.html
- 根據上面日誌中的提示資訊,可以確定 222222 這個 ID 號,在 pg_type 表中無法查詢到。
# select * from pg_type where oid = '222222';
typname | typnamespace | typowner | typlen | typbyval | typtype | typcategory | typispreferred | typisdefined | typdelim | typrelid | typelem | typarray | typinput | typoutput | typreceive | typsend | typmodin | typmodout | typanalyze
| typalign | typstorage | typnotnull | typbasetype | typtypmod | typndims | typdefaultbin | typdefault
---------+--------------+----------+--------+----------+---------+-------------+----------------+--------------+----------+----------+---------+----------+----------+-----------+------------+---------+----------+-----------+------------
+----------+------------+------------+-------------+-----------+----------+---------------+------------
(0 rows)
- 分析 pg_proc 表結構。檢視 pg_proc 表中對 pg_type.oid 引用的相關欄位。
# select provariadic,prorettype,proallargtypes,proargtypes from pg_proc where provariadic = '222222' or prorettype = '222222' or proallargtypes @> '{222222}' or proargtypes @> '222222';
provariadic | prorettype | proallargtypes | proargtypes
-------------+------------+----------------+--------------
0 | 222222 | | 2950 2950 16
(1 row)
- 查詢到 prorettype 欄位中使用到了 222222 這個 ID。
解決方案
- 將 pg_proc 表的 proname 欄位也輸出,確認函式名稱。
# select proname,provariadic,prorettype,proallargtypes,proargtypes from pg_proc where provariadic = '222222' or prorettype = '222222' or proallargtypes @> '{222222}' or proargtypes @> '222222';
proname | provariadic | prorettype | proallargtypes | proargtypes
------------------------------+-------------+------------+----------------+--------------
getuserpermissionsbyentityid | 0 | 222222 | | 2950 2950 16
(1 row)
-
根據 getuserpermissionsbyentityid 函式名稱,在資料庫中查詢到該函式。
- 檢視到該函式的返回型別為 permissions_view。
在 pg_type 表中查詢型別名稱為 permissions_view 的型別是否存在。
# select oid from pg_type where typname = 'permissions_view';
oid
--------
236728
(1 row)
查詢到 permissions_view 型別的 oid 號為 236728。(如果未查詢到需要先手動 insert 這條資料,再查詢出 oid)。
修改 pg_proc 表中 prorettype 欄位的引用 ID 為 236728。
# update pg_proc set prorettype = '236728' where proname = 'getuserpermissionsbyentityid';
UPDATE 1
- 再次進行備份成功。
2018-03-08 00:49:49 4677: Start of engine-backup mode backup scope all file /root/ovirt-engine.bak
2018-03-08 00:49:49 4677: Backing up:
2018-03-08 00:49:49 4677: Generating pgpass
2018-03-08 00:49:49 4677: Creating temp folder /tmp/engine-backup.4n8mAdmak4/tar
2018-03-08 00:49:49 4677: - Files
2018-03-08 00:49:49 4677: Backing up files to /tmp/engine-backup.4n8mAdmak4/tar/files
2018-03-08 00:49:50 4677: - Engine database 'engine'
2018-03-08 00:49:50 4677: Backing up database to /tmp/engine-backup.4n8mAdmak4/tar/db/engine_backup.db
2018-03-08 00:49:51 4677: Creating md5sum at /tmp/engine-backup.4n8mAdmak4/tar/md5sum
2018-03-08 00:49:53 4677: Packing into file '/root/ovirt-engine.bak'
2018-03-08 00:49:53 4677: Creating tarball /root/ovirt-engine.bak
2018-03-08 00:50:06 4677: Done.
相關文章
- NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load xxxx錯誤解決方法ErrorAIXMLHTTP
- PostgreSQL提示:‘psql: FATAL: ”Peer authentication failed for user ”postgres“’錯誤SQLAI
- PostgreSQL error 錯誤碼SQLError
- 精讀《Promise.all, Replace, Type Lookup...》Promise
- 【Redis】錯誤:failed: Hostname must not be empty or nullRedisAINull
- Github錯誤之failed to push some refs toGithubAI
- VMware vmdk錯誤: Failed to lock the file.AI
- Installation failed with message INSTALL_FAILED_USER_RESTRICTED錯誤AIREST
- 編譯錯誤 --- does not name a type和field `XX' has incomplete type編譯
- eclipse :報錯 ‘XXXX‘ does not name a type的解決辦法Eclipse
- ORA-600(504)(row cache objects)錯誤Object
- 常見的 PostgreSQL 升級錯誤SQL
- 編譯錯誤--------:XX does not name a type和field `XX' has incomplete type編譯
- MYSQL中 TYPE=MyISAM 錯誤的解決方法MySql
- `QtValidLicenseForCoreModule' does not name a type 錯誤的解決QTREM
- 實體類註解錯誤:Could not determine type for:
- eclipse中:The type java.lang.object cannot be resolved錯誤(jdk配置錯誤)EclipseJavaObjectJDK
- 安裝CLUSTER碰到 Assertion failed offset fFileSize錯誤AI
- centos 重啟掛載錯誤 failed to mount /backupCentOSAI
- xcode6編譯錯誤,提示Expected a typeXCode編譯
- 如何處理ABAP DDIC_TYPE_INCONSISTENCY錯誤
- ndk編譯錯誤:error: 'override' does not name a type編譯ErrorIDE
- 微軟BI 之SSIS 系列 - Lookup 元件的使用與它的幾種快取模式 - Full Cache, Partial Cache, NO Cache...微軟元件快取模式
- Spring Boot配置錯誤:Failed to determine a suitable driver classSpring BootAIUI
- INSTALL_FAILED_NO_MATCHING_ABIS錯誤解決AI
- oracle ASM錯誤Initializing the Oracle ASMLib driver:[FAILED]OracleASMAI
- 遷移過程中出現的open failed錯誤AI
- 記一次OPatch failed with error code 73錯誤AIError
- 通俗易懂解釋一類和二類錯誤(Type I Error Type II Error)Error
- 使用AFNetworking 2.0 請求資料時出現錯誤 Request failed: unacceptable content-type: text/html 解決方法AIHTML
- 使用@Service註解出現No bean named 'xxxx' available]錯誤BeanAI
- Brew 升級更新錯誤"Failed to install vendor Ruby."AI
- [sublime xftp外掛] Host key verification failed ,錯誤處理FTPAI
- myeclipse中提示Hot Code Replace Failed提示窗錯誤EclipseAI
- 解決錯誤:ASP.NET Error: Failed to access IIS metabaseASP.NETErrorAI
- Failed to run the WC DB work queue associated with 錯誤的解決AI
- Genymotion錯誤之INSTALL_FAILED_CPU_ABI_INCOMPATIAI
- wp7 toolkit編譯錯誤 Xap packaging failed編譯AI