ActiveRecord :: StatementInvalid:PG :: DataCorrupted:ERROR

时间:2014-04-11 22:51:51

标签: postgresql

这是完整的错误消息

ActiveRecord :: StatementInvalid:PG :: DataCorrupted:错误:无法读取文件中的块0" base / 50711/50722":只读取8192字节中的0

这可能是什么原因?

1 个答案:

答案 0 :(得分:0)

来自md.c的错误报告。我认为你的块被破坏了。你的文件系统设置或阻止设备的设置不强? 你可以设置zero_damaged_pa​​ges跳过这个块。

if (nbytes != BLCKSZ)
{
        if (nbytes < 0)
                ereport(ERROR,
                                (errcode_for_file_access(),
                                 errmsg("could not read block %u in file \"%s\": %m",
                                                blocknum, FilePathName(v->mdfd_vfd))));

        /*
         * Short read: we are at or past EOF, or we read a partial block at
         * EOF.  Normally this is an error; upper levels should never try to
         * read a nonexistent block.  However, if zero_damaged_pages is ON or
         * we are InRecovery, we should instead return zeroes without
         * complaining.  This allows, for example, the case of trying to
         * update a block that was later truncated away.
         */
        if (zero_damaged_pages || InRecovery)
                MemSet(buffer, 0, BLCKSZ);
        else
                ereport(ERROR,
                                (errcode(ERRCODE_DATA_CORRUPTED),
                                 errmsg("could not read block %u in file \"%s\": read only %d of %d bytes",
                                                blocknum, FilePathName(v->mdfd_vfd),
                                                nbytes, BLCKSZ)));
}