问题
Postgresql12 连接时提示 错误:关系“global/1213”中的块0存在无效项
解决方案
提示:此操作将销毁数据,即损坏页面上的所有行!但是,它允许您跳过错误,并从表中可能存在的任何未损坏的页面中检索行。
1.启动psql
,查看是否启用了zero_damaged_pages
。
postgres=# show zero_damaged_pages;
zero_damaged_pages
--------------------
off
(1 行记录)
2.如果没有启用,则开启zero_damaged_pages
。
postgres=# SET zero_damaged_pages=on;
SET
开启后,再查询一下其状态
postgres=# show zero_damaged_pages;
zero_damaged_pages
--------------------
on
(1 行记录)
3.执行查询,数据库会自动开始清零操作
postgres=# SELECT DISTINCT datlastsysoid FROM pg_database;
警告: 关系 "global/1213" 中的块 0 无效的页;正在对页进行清零操作
datlastsysoid
---------------
13317
(1 行记录)
参考
标签:1213,damaged,postgresql,postgres,global,zero,pages From: https://www.cnblogs.com/mayhot/p/16642855.htmlzero_damaged_pages (boolean)
Detection of a damaged page header normally causes PostgreSQL to report an error, aborting the current transaction. Setting zero_damaged_pages to on causes the system to instead report a warning, zero out the damaged page in memory, and continue processing. This behavior will destroy data, namely all the rows on the damaged page. However, it does allow you to get past the error and retrieve rows from any undamaged pages that might be present in the table. It is useful for recovering data if corruption has occurred due to a hardware or software error. You should generally not set this on until you have given up hope of recovering data from the damaged pages of a table. Zeroed-out pages are not forced to disk so it is recommended to recreate the table or the index before turning this parameter off again. The default setting is off, and it can only be changed by a superuser.