Skip to content

Instantly share code, notes, and snippets.

View mitchtchesnitch's full-sized avatar

Mircea Ionascu mitchtchesnitch

View GitHub Profile
@mitchtchesnitch
mitchtchesnitch / postgres_recovery.md
Created April 28, 2022 18:25 — forked from supix/postgres_recovery.md
Postgres error: Missing chunk 0 for toast value in pg_toast

The problem

In some cases, it is possible that PostgreSQL tables get corrupted. This can happen in case of hardware failures (e.g. hard disk drives with write-back cache enabled, RAID controllers with faulty/worn out battery backup, etc.), as clearly reported in this wiki page. Furthermore, it can happen in case of incorrect setup, as well.

One of the symptoms of such corruptions is the following message:

ERROR: missing chunk number 0 for toast value 123456 in pg_toast_45678

This almost surely indicates that a corrupted chunk is present within a table file. But there is a good way to get rid of it.