gitlab报 ERROR: missing chunk number 3 for toast value 108064 in pg_toast_2619

问题:

服务器掉电重启后gitlab报gitlab报 ERROR: missing chunk number 3 for toast value 108064 in pg_toast_2619

报错原因:

某张表关联的toast表的data发生损坏

 

解决方法:

1. 连接pgsql数据库

#su - gitlab-psql              // 切换到数据库使用的用户
$psql -h /var/opt/gitlab/postgresql -d gitlabhq_production

2. 根据错误信息定位哪张表的toast有问题

3. 修复有问题的表

gitlabhq_production=#REINDEX table pg_toast.pg_toast_2619;
gitlabhq_production=#REINDEX table pg_statistic;
gitlabhq_production=#VACUUM ANALYZE pg_statistic;

4. 执行如下定位表中损坏的数据行

DO $$ 
declare 
    v_rec record; 
BEGIN
    for v_rec in SELECT * FROM pg_statistic loop
        raise notice ‘Parameter is:%‘, v_rec.ctid; 
        raise notice ‘Parameteris:‘%, v_rec;
    end loop;
END;
$$
LANGUAGE plpgsql;

5. 删除第4步中定位的错误记录

gitlabhq_production=#delete from pg_statistic where ctid=‘(50,3)’;

6. 重复执行第4,5步直至全部有问题的记录被清除

posted @ 2022-03-14 18:08  默读自我  阅读(203)  评论(0)    收藏  举报