Re: Réparer pg_depend

From: Flavio Henrique Araque Gurgel <fhagur(at)gmail(dot)com>
To: pgsql-fr-generale(at)postgresql(dot)org
Subject: Re: Réparer pg_depend
Date: 2015-10-05 13:04:07
Message-ID: 56127547.8090101@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-fr-generale

> Bonjour,
>
> Un dump de ma BDD à planté il y a peu. Voilà l'erreur :
>
> ERROR: invalid page in block 252 of relation base/24585/12003

Ça veut dire que la relation est corrompue.

> STATEMENT: SELECT c.tableoid, c.oid, c.relname, c.relacl, c.relkind,
> c.relnamespace, (SELECT rolname FROM pg_catalog.pg_roles WHERE oid =
> c.relowner) AS rolname, c.relchecks, c.relhastriggers, c.relhasindex,
> c.relhasrules, c.relhasoids, c.relfrozenxid, c.relminmxid, tc.oid AS
> toid, tc.relfrozenxid AS tfrozenxid, tc.relminmxid AS tminmxid,
> c.relpersistence, c.relispopulated, c.relreplident, c.relpages, CASE
> WHEN c.reloftype <> 0 THEN c.reloftype::pg_catalog.regtype ELSE NULL END
> AS reloftype, d.refobjid AS owning_tab, d.refobjsubid AS owning_col,
> (SELECT spcname FROM pg_tablespace t WHERE t.oid = c.reltablespace) AS
> reltablespace,
> array_to_string(array_remove(array_remove(c.reloptions,'check_option=local'),'check_option=cascaded'),
> ', ') AS reloptions, CASE WHEN 'check_option=local' = ANY (c.reloptions)
> THEN 'LOCAL'::text WHEN 'check_option=cascaded' = ANY (c.reloptions)
> THEN 'CASCADED'::text ELSE NULL END AS checkoption,
> array_to_string(array(SELECT 'toast.' || x FROM unnest(tc.reloptions)
> x), ', ') AS toast_reloptions FROM pg_class c LEFT JOIN pg_depend d ON
> (c.relkind = 'S' AND d.classid = c.tableoid AND d.objid = c.oid AND
> d.objsubid = 0 AND d.refclassid = c.tableoid AND d.deptype = 'a') LEFT
> JOIN pg_class tc ON (c.reltoastrelid = tc.oid) WHERE c.relkind in ('r',
> 'S', 'v', 'c', 'm', 'f') ORDER BY c.oid
>
> J'ai donc cherché ce qui n'allait pas :
> select relfilenode,relname from pg_class where relfilenode = 12003
> => 12003;"pg_depend"
>
> En voulant reindexer :
> REINDEX TABLE pg_depend;
> => ERROR: invalid page in block 252 of relation base/24585/12003

La table pg_depend contient les relations entre les divers objets de la
base pour permettre, par exemple, que une commande DROP... CASCADE
supprime aussi les autres tables associées.

Le plus sûr dans ce cas c'est recréer le cluster PostgreSQL et restaurer
une sauvegarde reconnue comme bonne.

> OS : Windows 2012 R2 64bits
> PG : "PostgreSQL 9.4.4, compiled by Visual C++ build 1800, 64-bit"

Les causes plus connues de ce type de corruption :
- barrettes de RAM défectueuses (ça m'est arrivé trois fois déjà)
- fsync en mode off dans la configuration
- autres bugs connues qui peuvent avoir causé la corruption dans des
versions anciennes qui ont été mises a jour a partir de pg_upgrade.

Flavio Gurgel

--
Envoi via la liste pgsql-fr-generale (pgsql-fr-generale(at)postgresql(dot)org)

In response to

Responses

Browse pgsql-fr-generale by date

  From Date Subject
Next Message Thomas RAFFIN 2015-10-05 13:24:26 Re: Réparer pg_depend
Previous Message Thomas RAFFIN 2015-10-05 12:42:15 Réparer pg_depend