pieclouddb

PieCloudDB error: toast table is corrputed


I'm new to PieCloudDB database, I encountered a problem that toast table is corrupted, how can I fix it?

missing chunk number 0 for toast value 32789 in pg_toast_2619


Solution

  • Well, I tried to solve this problem using my experience in PG and surprisingly it worked.

    I found the toast table based on oid, it is pg_statistic

    select 2619::regclass;
    

    then I used a stored procedure to find the bad data:

    DO $$ 
    DECLARE
      v_rec record; 
    BEGIN 
    FOR v_rec in SELECT * FROM pg_statistic loop 
    raise notice ‘Parameter is:‘, v_rec.ctid; 
    raise notice ‘Parameter is:’, v_rec;
    END loop; 
    END;
    $$ 
    LANGUAGE plpgsql;
    

    I found that it stopped when ctid=(50,2).

    Then I selected the data of (50,2) and (50,3) respectively and found that the problem occurred at (50,3), so I deleted it

    select * from pg_statistic where ctid= '(50,2)';
    select * from pg_statistic where ctid= '(50,3)';
    
    delete from pg_statistic where ctid = '(50,3)';
    

    Finally I re-indexed and it no longer errors.

    REINDEX table pg_toast.pg_toast_2619; 
    REINDEX table pg_statistic; 
    VACUUM ANALYZE pg_statistic;