pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
To: lucas.valardao@gmail.com
To: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16844: Relation mapping file "global/pg_filenode.map" contains invalid data
Date: Fri, 29 Jan 2021 11:40:44 +0900 (JST)
Message-ID: <20210129.114044.1299501672229763203.horikyota.ntt@gmail.com> (raw)
In-Reply-To: <16844-8883553903fb0df2@postgresql.org>
References: <16844-8883553903fb0df2@postgresql.org>

At Thu, 28 Jan 2021 13:16:32 +0000, PG Bug reporting form <noreply@postgresql.org> wrote in 
> The following bug has been logged on the website:
> 
> Bug reference:      16844
> Logged by:          Lucas Valardao
> Email address:      lucas.valardao@gmail.com
> PostgreSQL version: 9.6.0
> Operating system:   Windows Server 2012 R2
> Description:        
> 
> Good morning, dear!
> 
> We went through a hacker attack at our company, and corrupted some data
> folders.
> 
> Is there any way to correct this error: "Relation mapping file
> "global/pg_filenode.map" contains invalid data".

This is not a bug report. You should have posted this into -general
list.

> We have no backup, this would be our last hope!

Note that you should take a copy of the whole cluster before trying
restoration.

The file contains physical-file mappings for shared catalog tables.

The most easy way I think that possibly restores the file is just
copying the same file from a freshly-create cluster on the same
platform (It might be platform-dependent, but I'm not sure.) and the
same server major version.  If you're lucky enough it might work.

If it doesn't work, the file has been updated since the broken cluster
was created.  In that case, there might be a "RelMap" WAL record in
your recent WAL files by a quite low possibility. The record contains
the whole content of the file. Records corresponding to
global/pg_relfilenode.map has databaseid = 0.

pg_xlogdump .../pg_xlog/000xxxxxx | grep RelMap

rmgr: RelMap      len (rec/tot):    553/   553, tx:        510, lsn: 0/01639208, prev 0/016391D0, desc: UPDATE database 0 tablespace 1663 size 512

(this is not a real one since no workable 9.6 for me for now.)

There's no established way to restore the file from a WAL record
content manually, but the steps would be like the follows.

1. You can find the record location from the WAL description. In the
 above case, you will find the record at 0x639208 in the file.

2. The file content starts by a fixed magic header byte sequence.
   "00 59 27 17"  (0x592717). and the size should be 512 bytes.

Otherwise..., the last choice is inspecting the cluster in
binary-level to infer the relation map then create the file from
scratch... Almost impossible.

regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center





view thread (5+ messages)  latest in thread

Message-ID: <20210129.114044.1299501672229763203.horikyota.ntt@gmail.com>
Permalink:  ../20210129.114044.1299501672229763203.horikyota.ntt@gmail.com/
Also on:    postgresql.org/message-id/20210129.114044.1299501672229763203.horikyota.ntt@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: horikyota.ntt@gmail.com, lucas.valardao@gmail.com
  Subject: Re: BUG #16844: Relation mapping file "global/pg_filenode.map" contains invalid data
  In-Reply-To: <20210129.114044.1299501672229763203.horikyota.ntt@gmail.com>
  References: <16844-8883553903fb0df2@postgresql.org> <20210129.114044.1299501672229763203.horikyota.ntt@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox